[Pkg-javascript-commits] [node-browser-unpack] 26/40: fix case where uglify turns strings into identifiers
Bastien Roucariès
rouca at moszumanska.debian.org
Thu Nov 9 12:27:25 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-browser-unpack.
commit 032c4892e1f8808868f11d9a7cee593c5ff37b32
Author: mattdesl <dave.des at gmail.com>
Date: Sun Apr 26 21:43:25 2015 -0400
fix case where uglify turns strings into identifiers
---
index.js | 5 ++++-
test/uglified.js | 11 ++++++++++-
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/index.js b/index.js
index abe867a..fd5ee69 100644
--- a/index.js
+++ b/index.js
@@ -60,7 +60,10 @@ module.exports = function (src) {
var depProps = file.value.elements[1].properties;
var deps = depProps.reduce(function (acc, dep) {
- acc[dep.key.value] = dep.value.value;
+ var key = dep.key.type === 'Literal'
+ ? dep.key.value
+ : dep.key.name;
+ acc[key] = dep.value.value;
return acc;
}, {});
var row = {
diff --git a/test/uglified.js b/test/uglified.js
index 8a33490..9954c9b 100644
--- a/test/uglified.js
+++ b/test/uglified.js
@@ -8,10 +8,19 @@ var fs = require('fs');
var src = fs.readFileSync(__dirname + '/files/uglified.js', 'utf8');
test('uglified', function (t) {
- t.plan(2);
+ t.plan(3);
t.doesNotThrow(function() {
var p = pack({ raw: true });
var rows = unpack(src);
t.equal(rows.length, 3, 'should unpack 3 rows');
}, 'should not throw');
+
+ t.deepEquals(deps(src), ['./foo.js', 'gamma']);
+
+ function deps(src) {
+ var rows = unpack(src);
+ return rows.reduce(function(prev, row) {
+ return prev.concat(Object.keys(row.deps));
+ }, []);
+ }
});
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-browser-unpack.git
More information about the Pkg-javascript-commits
mailing list