Skip to content

Commit

Permalink
Make dependencies parsing optional (#19)
Browse files Browse the repository at this point in the history
* Handle `xml2js` import error
* Fix workflow for JS changes
* Fix linter settings
  • Loading branch information
ogonkov committed Jul 27, 2020
1 parent bf167cd commit a1ba499
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 9,
"ecmaVersion": 11,
"sourceType": "module"
},
"rules": {
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
branches: [ master ]
paths:
- '*.js'
- 'src/*'
- 'test/*'
- 'package.json'

Expand Down
4 changes: 2 additions & 2 deletions src/get-dependencies.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import path from 'path';
import fs from 'fs';
import util from 'util';
import {parseStringPromise} from 'xml2js';
import {getParser} from './get-parser';
import {NODE_ATTRIBUTES} from './nodes';
import {filterNodes} from './filter-nodes';

Expand All @@ -24,7 +24,7 @@ function getSrcAttribute({item: [attributes]}) {
* @return {Promise<Set<string>>}
*/
async function getFileImports(source) {
const root = await parseStringPromise(source);
const root = await getParser().then((parseString) => parseString(source));
const nodes = filterNodes(root, [
'fest:include',
'fest:insert'
Expand Down
5 changes: 5 additions & 0 deletions src/get-parser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export function getParser() {
return import('xml2js').then(function({parseStringPromise}) {
return parseStringPromise;
});
}

0 comments on commit a1ba499

Please sign in to comment.