Skip to content

Commit

Permalink
Merge branch 'master' into tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
bcomnes committed Dec 25, 2017
2 parents 76c9161 + 9aa7130 commit 46acb22
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
9 changes: 8 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ var fastFind = require('./find-fast');

var requireRe = /\brequire\b/;


function getParseOpts (opts) {
opts = opts || {};
return {
ecmaVersion: defined(opts.ecmaVersion, 8),
ecmaVersion: defined(opts.ecmaVersion, 9),
sourceType: opts.sourceType,
ranges: defined(opts.ranges, opts.range),
locations: defined(opts.locations, opts.loc),
Expand Down Expand Up @@ -65,6 +66,12 @@ exports.find = function (src, opts) {
if (arg.type === 'Literal') {
modules.strings.push(arg.value);
}
else if (arg.type === 'TemplateLiteral'
&& arg.quasis.length === 1
&& arg.expressions.length === 0) {

modules.strings.push(arg.quasis[0].value.raw);
}
else {
modules.expressions.push(src.slice(arg.start, arg.end));
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "detective",
"description": "find all require() calls by walking the AST",
"version": "4.6.0",
"version": "4.7.1",
"repository": {
"type": "git",
"url": "git://github.com/browserify/detective.git"
Expand Down
2 changes: 1 addition & 1 deletion readme.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ node is a require call
* `opts.parse` - supply options directly to
[acorn](https://npmjs.org/package/acorn) with some support for esprima-style
options `range` and `loc`
* `opts.ecmaVersion` - default: 8
* `opts.ecmaVersion` - default: 9

# install

Expand Down
2 changes: 2 additions & 0 deletions test/complicated.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ var detective = require('../');

var sources = [
'require("a")',
"require('a')",
'require(`a`)',
';require("a")',
' require("a")',
'void require("a")',
Expand Down

0 comments on commit 46acb22

Please sign in to comment.