Skip to content

Commit c55c3d8

Browse files
authored
Support for .as extension (as-pect#356)
* Support for .as extension * Copy synchronously * let's try this * package locks Co-authored-by: Joshua Tenner <tenner.joshua@gmail.com> Credit goes to @munrocket for the initial work, even if I replaced some of the logic with glob logic
1 parent f65c8f2 commit c55c3d8

File tree

5 files changed

+130
-124
lines changed

5 files changed

+130
-124
lines changed

index.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

package-lock.json

Lines changed: 69 additions & 70 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/cli/src/run.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,24 @@ export function run(cliOptions: Options, compilerArgs: string[]): void {
376376
}
377377
}
378378

379+
// If another extension is used create copy of assembly/**/*.ts files
380+
if (flags["--extension"]) {
381+
console.log(chalk`{bgWhite.black [Log]} Changing extension for injected assembly files`);
382+
const newExt = flags["--extension"][0].replace(".", ""); // without dot should work
383+
const assemblyFolder = path.dirname(require.resolve("@as-pect/assembly/assembly/index.ts"));
384+
385+
const files = glob.sync(path.join(assemblyFolder, "**/*.ts"));
386+
387+
files.forEach(file => {
388+
const dirname = path.dirname(file);
389+
const basename = path.basename(file, path.extname(file));
390+
fs.copyFileSync(file, path.join(dirname, basename + "." + newExt));
391+
});
392+
}
393+
379394
// must include the assembly/index.ts file located in the assembly package
380-
const entryPath = require.resolve("@as-pect/assembly/assembly/index.ts");
395+
const entryExt = !flags["--extension"] ? "ts" : flags["--extension"][0].replace(".", "");
396+
const entryPath = require.resolve("@as-pect/assembly/assembly/index." + entryExt);
381397
const relativeEntryPath = path.relative(process.cwd(), entryPath);
382398

383399
// add the relativeEntryPath of as-pect to the list of compiled files for each test

0 commit comments

Comments
 (0)