Skip to content

Commit

Permalink
feat(cli): use json5 to support writing comment in wxa.config file
Browse files Browse the repository at this point in the history
  • Loading branch information
Genuifx committed Mar 6, 2020
1 parent 09e12f2 commit fd87b7e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
6 changes: 3 additions & 3 deletions packages/wxa-cli/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/wxa-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"htmlparser2": "^3.10.1",
"inquirer": "^6.2.0",
"js-base64": "^2.4.0",
"json5": "^2.1.1",
"mkdirp": "^0.5.1",
"node-notifier": "^5.2.1",
"promise.prototype.finally": "^3.1.0",
Expand Down
9 changes: 4 additions & 5 deletions packages/wxa-cli/src/compilers/config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import {readFile} from '../utils';
import logger from '../helpers/logger';
import debugPKG from 'debug';

let debug = debugPKG('WXA:ConfigCompiler');
import json5 from 'json5';

export default class ConfigCompiler {
parse(filepath, code) {
Expand All @@ -12,11 +10,12 @@ export default class ConfigCompiler {
logger.error(`文件不存在, ${filepath}`);
return Promise.reject(null);
}
// debug('code, %O', JSON.parse(code));

let jsonData = json5.parse(code);

return Promise.resolve({
kind: 'json',
json: JSON.parse(code),
json: jsonData,
});
}
}
1 change: 0 additions & 1 deletion packages/wxa-cli/src/compilers/wxa.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import logger from '../helpers/logger';
import DependencyResolver from '../helpers/dependencyResolver';
import defaultPret from '../const/defaultPret';
import {parseXML, serializeXML} from './xml';
import domSerializer from 'dom-serializer';

const SCRIPT_TAG = 'script';
const CONFIG_TAG = 'config';
Expand Down

0 comments on commit fd87b7e

Please sign in to comment.