diff --git a/index.js b/index.js index 7f1221d..674e4a3 100644 --- a/index.js +++ b/index.js @@ -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); } @@ -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'); diff --git a/test/index.js b/test/index.js index af91523..91ca243 100644 --- a/test/index.js +++ b/test/index.js @@ -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(); }); @@ -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(); });