Skip to content

Commit

Permalink
feat: pass filename to detective
Browse files Browse the repository at this point in the history
  • Loading branch information
AndersDJohnson committed Jul 16, 2022
1 parent 94555ad commit 6e674f1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ function precinct(content, options = {}) {
}

if (theDetective) {
dependencies = theDetective(ast, options[type]);
dependencies = theDetective(ast, {
...options[type],
filename: options.filename,
treePath: options.treePath,
});
} else {
debug('no detective found for: %s', type);
}
Expand All @@ -132,7 +136,7 @@ function detectiveEs6Cjs(ast, detectiveOptions) {
* @return {String[]}
*/
precinct.paperwork = (filename, options = {}) => {
options = { includeCore: true, ...options };
options = { includeCore: true, filename, ...options };

const fileSystem = options.fileSystem || fs;
const content = fileSystem.readFileSync(filename, 'utf8');
Expand Down
4 changes: 2 additions & 2 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ describe('node-precinct', () => {
amd: config.amd
});

assert.deepEqual(stub.args[0][1], config.amd);
assert.deepEqual(stub.args[0][1].skipLazyLoaded, config.amd.skipLazyLoaded);
revert();
});

Expand Down Expand Up @@ -264,7 +264,7 @@ describe('node-precinct', () => {

precinct(read('amd.js'), config);

assert.deepEqual(stub.args[0][1], config.amd);
assert.deepEqual(stub.args[0][1].skipLazyLoaded, config.amd.skipLazyLoaded);
revert();
});

Expand Down

0 comments on commit 6e674f1

Please sign in to comment.