Merge pull request #8058 from backstage/rugvip/cba-fix

create-app: fix windows file copy and mocking
This commit is contained in:
Patrik Oldsberg
2021-11-15 23:38:09 +01:00
committed by GitHub
2 changed files with 11 additions and 3 deletions
+1 -1
View File
@@ -25,7 +25,7 @@ jest.mock('./lib/tasks');
beforeAll(() => {
mockFs({
'package.json': '', // required by `findPaths(__dirname)`
[`${__dirname}/package.json`]: '', // required by `findPaths(__dirname)`
'templates/': mockFs.load(path.resolve(__dirname, '../templates/')),
});
});
+10 -2
View File
@@ -19,7 +19,12 @@ import fs from 'fs-extra';
import handlebars from 'handlebars';
import ora from 'ora';
import recursive from 'recursive-readdir';
import { basename, dirname, resolve as resolvePath } from 'path';
import {
basename,
dirname,
resolve as resolvePath,
relative as relativePath,
} from 'path';
import { exec as execCb } from 'child_process';
import { packageVersions } from './versions';
import { promisify } from 'util';
@@ -85,7 +90,10 @@ export async function templatingTask(
});
for (const file of files) {
const destinationFile = file.replace(templateDir, destinationDir);
const destinationFile = resolvePath(
destinationDir,
relativePath(templateDir, file),
);
await fs.ensureDir(dirname(destinationFile));
if (file.endsWith('.hbs')) {