Skip to content

Commit

Permalink
quick fix - windows path sep
Browse files Browse the repository at this point in the history
  • Loading branch information
aperron committed May 4, 2021
1 parent f8353ce commit a5f9e68
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
20 changes: 9 additions & 11 deletions src/test/test3.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { interfaceName } = require('./test1.config');

const path = require('path');
/**
* @type {import('../../index').IConfigOptions}
*/
Expand All @@ -12,20 +12,18 @@ const config = {
inputGroup: 'src/test/components/content/',
output: 'src/test/out3/',
enum: true,
fieldType: (fieldType) => { if(fieldType === 'datetime') return 'string'},
fieldType: (fieldType) => { if (fieldType === 'datetime') return 'string' },
// fieldName: (fieldName) => fieldName.replace('_', '-'),
interfaceName: name => `X${name}`.replace(/ /g, ''),
outputFileName: (interfaceName, filename) => filename.indexOf('test/components/content/') !== -1 ? `content/${interfaceName}` : interfaceName,
enumName: (name, interfaceName) =>`Enum${interfaceName}${name}`,
outputFileName: (interfaceName, filename) => filename.indexOf(`test${path.sep}components${path.sep}content${path.sep}`) !== -1 ? `content${path.sep}${interfaceName}` : interfaceName,
enumName: (name, interfaceName) => `Enum${interfaceName}${name}`,
excludeField: (interfaceName, fieldName) => fieldName === 'email_field',
addField: (interfaceName) => {
if(interfaceName === 'Xtestobject') return [
{
name: "created_by",
type: "string"
}
]
if (interfaceName === 'Xtestobject') return [{
name: "created_by",
type: "string"
}]
},
importAsType: (interfaceName) => interfaceName !== 'Xuser'
}
module.exports = config;
module.exports = config;
4 changes: 2 additions & 2 deletions src/ts-exporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ class Converter {
const outputFile = path.resolve(this.config.output, 'index.ts');

const output = this.strapiModels
.map(s => `export * from './${s.ouputFile}';`)
.map(s => `export * from './${s.ouputFile.replace('\\', '/')}';`)
.sort()
.join('\n');
fs.writeFileSync(outputFile, output + '\n');
Expand Down Expand Up @@ -216,7 +216,7 @@ class Converter {
let rel = path.normalize(path.relative(path.dirname(m.ouputFile), path.dirname(f.ouputFile)));
rel = path.normalize(rel + path.sep + path.basename(f.ouputFile))
if (!rel.startsWith('..')) rel = '.' + path.sep + rel;
return rel;
return rel.replace('\\', '/').replace('\\', '/');
}
return found ? `import ${(this.config.importAsType && this.config.importAsType(m.interfaceName) ? 'type ' : '')}{ ${found.interfaceName} } from '${toFolder(found)}';` : '';
};
Expand Down

0 comments on commit a5f9e68

Please sign in to comment.