Skip to content

Commit

Permalink
chore: teach harness to support replacements in contents
Browse files Browse the repository at this point in the history
  • Loading branch information
nulltoken committed Feb 15, 2020
1 parent 8f4ae5c commit ed7f454
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions test-harness/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,21 @@ describe('cli acceptance tests', () => {

beforeAll(async () => {
await Promise.all(
scenario.assets.map(async ([asset, contents]) => {
scenario.assets.map(async ([asset]) => {
const tmpFileHandle = await tmpFile();
tmpFileHandles.set(asset, tmpFileHandle);

const normalizedName = normalize(tmpFileHandle.name);

replacements[asset] = normalizedName;
replacements[`${asset}|no-ext`] = normalizedName.replace(new RegExp(`${path.extname(normalizedName)}$`), '');
}),
);

await writeFileAsync(tmpFileHandle.name, contents, { encoding: 'utf8' }); // todo: apply replacements to contents
await Promise.all(
scenario.assets.map(async ([asset, contents]) => {
const replaced = applyReplacements(contents, replacements);
await writeFileAsync(replacements[asset], replaced, { encoding: 'utf8' });
}),
);
});
Expand Down

0 comments on commit ed7f454

Please sign in to comment.