Skip to content

Commit 46acb22

Browse files
authored
Merge branch 'master' into tokens
2 parents 76c9161 + 9aa7130 commit 46acb22

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ var fastFind = require('./find-fast');
66

77
var requireRe = /\brequire\b/;
88

9+
910
function getParseOpts (opts) {
1011
opts = opts || {};
1112
return {
12-
ecmaVersion: defined(opts.ecmaVersion, 8),
13+
ecmaVersion: defined(opts.ecmaVersion, 9),
1314
sourceType: opts.sourceType,
1415
ranges: defined(opts.ranges, opts.range),
1516
locations: defined(opts.locations, opts.loc),
@@ -65,6 +66,12 @@ exports.find = function (src, opts) {
6566
if (arg.type === 'Literal') {
6667
modules.strings.push(arg.value);
6768
}
69+
else if (arg.type === 'TemplateLiteral'
70+
&& arg.quasis.length === 1
71+
&& arg.expressions.length === 0) {
72+
73+
modules.strings.push(arg.quasis[0].value.raw);
74+
}
6875
else {
6976
modules.expressions.push(src.slice(arg.start, arg.end));
7077
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "detective",
33
"description": "find all require() calls by walking the AST",
4-
"version": "4.6.0",
4+
"version": "4.7.1",
55
"repository": {
66
"type": "git",
77
"url": "git://github.com/browserify/detective.git"

readme.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ node is a require call
6666
* `opts.parse` - supply options directly to
6767
[acorn](https://npmjs.org/package/acorn) with some support for esprima-style
6868
options `range` and `loc`
69-
* `opts.ecmaVersion` - default: 8
69+
* `opts.ecmaVersion` - default: 9
7070

7171
# install
7272

test/complicated.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ var detective = require('../');
33

44
var sources = [
55
'require("a")',
6+
"require('a')",
7+
'require(`a`)',
68
';require("a")',
79
' require("a")',
810
'void require("a")',

0 commit comments

Comments
 (0)