Comparing version 1.1.0-dev.20210821.6 to 1.1.0-dev.20210821.7
@@ -21,16 +21,19 @@ module.exports = { | ||
} | ||
ignore.push( | ||
path.resolve(this.tsconfigDir, this.tsconfig.compilerOptions.outDir), | ||
path.resolve(this.tsconfigDir, `${this.tsconfig.compilerOptions.outDir}/**/*`) | ||
); | ||
const files = include?.reduce((files, file) => this.glob.sync(file, { ignore }), []) || []; | ||
const files = include?.reduce((files, file) => [ ...files, ...this.glob.sync(file, { ignore })], []) || []; | ||
for (const file of files) { | ||
if (file.endsWith('.js') || (!this.tsconfig.compilerOptions?.allowTS && file.endsWith('.ts'))) continue; | ||
const relative = file.replace(path.resolve(file, path.relative(file, this.tsconfigDir)), '').split('/').splice(2).join('/'); | ||
const target = path.resolve(this.tsconfigDir, this.tsconfig.compilerOptions.outDir, relative); | ||
const outFile = file.replace(this.tsconfigDir, path.resolve(this.tsconfigDir, this.tsconfig.compilerOptions.outDir)); | ||
if (!fs.existsSync(path.dirname(target))) { | ||
fs.mkdirSync(path.dirname(target), { recursive: true }); | ||
if (!fs.existsSync(path.dirname(outFile))) { | ||
fs.mkdirSync(path.dirname(outFile), { recursive: true }); | ||
} | ||
if (fs.lstatSync(file).isDirectory() && !fs.existsSync(target)) { | ||
fs.mkdirSync(target, { recursive: true }); | ||
if (fs.lstatSync(file).isDirectory() && !fs.existsSync(outFile)) { | ||
fs.mkdirSync(outFile, { recursive: true }); | ||
} | ||
@@ -40,3 +43,3 @@ | ||
const fileContent = fs.readFileSync(file); | ||
fs.writeFileSync(path.resolve(target, path.basename(file)), fileContent); | ||
fs.writeFileSync(outFile, fileContent); | ||
} | ||
@@ -43,0 +46,0 @@ } |
{ | ||
"name": "tsc-hooks", | ||
"version": "1.1.0-dev.20210821.6", | ||
"version": "1.1.0-dev.20210821.7", | ||
"description": "Add tsc compiler hooks to your TypeScript project", | ||
@@ -5,0 +5,0 @@ "main": "run.js", |
108143
151