(assetName: string, to?: string)
| 20 | } |
| 21 | |
| 22 | export function copyAssets(assetName: string, to?: string) { |
| 23 | const seed = +Date.now(); |
| 24 | const tempRoot = join(getTestAssetsDir(), assetName + '-' + seed); |
| 25 | const root = assetDir(assetName); |
| 26 | |
| 27 | return Promise.resolve() |
| 28 | .then(() => { |
| 29 | const allFiles = glob.sync('**/*', { dot: true, cwd: root }); |
| 30 | |
| 31 | return allFiles.reduce((promise, filePath) => { |
| 32 | const toPath = |
| 33 | to !== undefined ? resolve(getTestProjectDir(), to, filePath) : join(tempRoot, filePath); |
| 34 | |
| 35 | return promise |
| 36 | .then(() => copyFile(join(root, filePath), toPath)) |
| 37 | .then(() => chmod(toPath, 0o777)); |
| 38 | }, Promise.resolve()); |
| 39 | }) |
| 40 | .then(() => tempRoot); |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * @returns a method that once called will restore the environment |
no test coverage detected