Skip to content

Commit

Permalink
Support for .as extension (as-pect#356)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
munrocket committed Jun 21, 2021
1 parent f65c8f2 commit c55c3d8
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 124 deletions.
9 changes: 0 additions & 9 deletions index.js

This file was deleted.

139 changes: 69 additions & 70 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 17 additions & 1 deletion packages/cli/src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,24 @@ export function run(cliOptions: Options, compilerArgs: string[]): void {
}
}

// If another extension is used create copy of assembly/**/*.ts files
if (flags["--extension"]) {
console.log(chalk`{bgWhite.black [Log]} Changing extension for injected assembly files`);
const newExt = flags["--extension"][0].replace(".", ""); // without dot should work
const assemblyFolder = path.dirname(require.resolve("@as-pect/assembly/assembly/index.ts"));

const files = glob.sync(path.join(assemblyFolder, "**/*.ts"));

files.forEach(file => {
const dirname = path.dirname(file);
const basename = path.basename(file, path.extname(file));
fs.copyFileSync(file, path.join(dirname, basename + "." + newExt));
});
}

// must include the assembly/index.ts file located in the assembly package
const entryPath = require.resolve("@as-pect/assembly/assembly/index.ts");
const entryExt = !flags["--extension"] ? "ts" : flags["--extension"][0].replace(".", "");
const entryPath = require.resolve("@as-pect/assembly/assembly/index." + entryExt);
const relativeEntryPath = path.relative(process.cwd(), entryPath);

// add the relativeEntryPath of as-pect to the list of compiled files for each test
Expand Down
Loading

0 comments on commit c55c3d8

Please sign in to comment.