[Pkg-javascript-commits] [node-detective] 100/119: pass "sourceType" option to acorn
Bastien Roucariès
rouca at moszumanska.debian.org
Wed Sep 6 09:44:39 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-detective.
commit 96f2115f5f0fb78b39690289922a9a041ae94573
Author: Andres Suarez <zertosh at gmail.com>
Date: Wed Jul 1 08:01:33 2015 -0400
pass "sourceType" option to acorn
fixes #54
---
index.js | 1 +
test/es6-module.js | 9 +++++++++
test/files/es6-module.js | 5 +++++
3 files changed, 15 insertions(+)
diff --git a/index.js b/index.js
index f16132a..9936d4a 100644
--- a/index.js
+++ b/index.js
@@ -8,6 +8,7 @@ function parse (src, opts) {
if (!opts) opts = {};
return aparse(src, {
ecmaVersion: defined(opts.ecmaVersion, 6),
+ sourceType: opts.sourceType,
ranges: defined(opts.ranges, opts.range),
locations: defined(opts.locations, opts.loc),
allowReserved: defined(opts.allowReserved, true),
diff --git a/test/es6-module.js b/test/es6-module.js
new file mode 100644
index 0000000..379c89c
--- /dev/null
+++ b/test/es6-module.js
@@ -0,0 +1,9 @@
+var test = require('tap').test;
+var detective = require('../');
+var fs = require('fs');
+var src = fs.readFileSync(__dirname + '/files/es6-module.js');
+
+test('es6-module', function (t) {
+ t.plan(1);
+ t.deepEqual(detective(src, {parse: {sourceType: 'module'}}), [ 'a', 'b' ]);
+});
diff --git a/test/files/es6-module.js b/test/files/es6-module.js
new file mode 100644
index 0000000..e05c1a0
--- /dev/null
+++ b/test/files/es6-module.js
@@ -0,0 +1,5 @@
+var a = require('a');
+
+export default function () {
+ var b = require('b');
+}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-detective.git
More information about the Pkg-javascript-commits
mailing list