Skip to content

Commit

Permalink
support json comments (#171)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jasper De Moor authored and devongovett committed Dec 11, 2017
1 parent 2e32662 commit 7bfe232
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"posthtml": "^0.9.2",
"resolve": "^1.4.0",
"serve-static": "^1.12.4",
"strip-json-comments": "^2.0.1",
"uglify-js": "^3.0.28",
"v8-compile-cache": "^1.1.0",
"worker-farm": "^1.4.1",
Expand Down
4 changes: 3 additions & 1 deletion src/utils/config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const fs = require('./fs');
const path = require('path');
const parseJson = require('parse-json');
const stripJsonComments = require('strip-json-comments');

const existsCache = new Map();

Expand Down Expand Up @@ -35,7 +36,8 @@ async function load(filepath, filenames, root = path.parse(filepath).root) {
return require(configFile);
}

return parseJson(await fs.readFile(configFile));
let configStream = await fs.readFile(configFile);
return parseJson(stripJsonComments(configStream.toString()));
}

return null;
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4728,7 +4728,7 @@ strip-indent@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/strip-indent/-/strip-indent-2.0.0.tgz#5ef8db295d01e6ed6cbf7aab96998d7822527b68"

strip-json-comments@~2.0.1:
strip-json-comments@^2.0.1, strip-json-comments@~2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a"

Expand Down

0 comments on commit 7bfe232

Please sign in to comment.