Skip to content

Commit

Permalink
Merge pull request #1 from afc163/fix-import-all
Browse files Browse the repository at this point in the history
Fix import RegExp for newline
  • Loading branch information
yiminghe committed Jun 8, 2016
2 parents 5b3caad + ad9f2e0 commit 1f6651b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Expand Up @@ -5,9 +5,9 @@ notifications:
- yiminghe@gmail.com

node_js:
- 0.12
- 5

script:
- npm test
- npm run cover
- cat ./coverage/lcov.info | node ./node_modules/coveralls/bin/coveralls
- cat ./coverage/lcov.info | node ./node_modules/coveralls/bin/coveralls
2 changes: 1 addition & 1 deletion index.js
@@ -1,7 +1,7 @@
'use strict';

var requireRegExp = /(?:[^.]|^)\s*require\s*\((\s*(['"])[^)'"]+\2\s*)\)/g;
var importRegExp = /(?:[^.]|^)\s*import[^'"\r\n]+(['"])([^'"]+)\1\s*;/g;
var importRegExp = /(?:[^.]|^)\s*import[^'"]+(['"])([^'"]+)\1\s*;/g;
var commentUtil = require('./lib/commentUtil');

function repeat(s, n) {
Expand Down
9 changes: 7 additions & 2 deletions tests/spec/import.js
Expand Up @@ -7,11 +7,16 @@ describe('match import', function () {
'import x from "3";',
'console.import("1")',
'/* import "2" */',
'import {z} from "4";'
'import {z} from "4";',
`import {
x,
y,
z,
} from "5";`,
].join('\n');

var ret = matchRequire.findAllImports(content);

expect(ret).to.eql(['3', '4']);
expect(ret).to.eql(['3', '4', '5']);
});
});

0 comments on commit 1f6651b

Please sign in to comment.