Skip to content

Commit

Permalink
fix: copyTemplate failed if tmpdir set to false
Browse files Browse the repository at this point in the history
  • Loading branch information
ianho committed Jan 10, 2024
1 parent aa6fd4c commit 513e087
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,27 @@ export class App {
async copyTemplate() {
await promisifyHooks(this.opts.beforeCopy, this.hookArgsWithOriginalResourcesAppDir);

await fs.copy(this.opts.dir, this.originalResourcesAppDir, {
filter: userPathFilter(this.opts),
dereference: this.opts.derefSymlinks,
});
if (this.opts.tmpdir === false) {
const filter = userPathFilter(this.opts);
const items = await fs.readdir(this.opts.dir);
await Promise.all(items.map(async item => {
const srcItem = path.join(this.opts.dir, item);
const destItem = path.join(this.originalResourcesAppDir, item);

const include = await filter(srcItem, destItem);
if (!include) return;

return fs.copy(srcItem, destItem, {
filter,
dereference: this.opts.derefSymlinks ?? true,
});
}));
} else {
await fs.copy(this.opts.dir, this.originalResourcesAppDir, {
filter: userPathFilter(this.opts),
dereference: this.opts.derefSymlinks ?? true,
});
}
await promisifyHooks(this.opts.afterCopy, this.hookArgsWithOriginalResourcesAppDir);
if (this.opts.prune) {
await promisifyHooks(this.opts.afterPrune, this.hookArgsWithOriginalResourcesAppDir);
Expand Down

0 comments on commit 513e087

Please sign in to comment.