Skip to content

Commit

Permalink
update/get-browser-globals/combine.js WIP sindresorhus#166
Browse files Browse the repository at this point in the history
  • Loading branch information
shapkarin committed Jul 6, 2020
1 parent 214f522 commit 6d26f17
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
yarn.lock
browser_vars.json
result_browser_vars.json
17 changes: 16 additions & 1 deletion update/get-browser-globals/combine.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,19 @@

const fs = require('fs');

const file = fs.readFileSync('./browser_vars.json');
const json = require('../../browser_vars.json');

const diff_array = function(oneObj, otherObj){
const defaultKeys = Object.keys(oneObj);
const yours = Object.keys(otherObj);

return defaultKeys.filter(key => !yours.includes(key));
};

const browser = json['jshint'];
const my = json['my'];

const difference = diff_array(browser, my).reduce(name => `\n${name}: true,\n`, '');

fs.writeFileSync('./result_browser_vars.json', `{ "result": \n\t${JSON.stringify(difference, null, '\t\t')}`);

2 changes: 1 addition & 1 deletion update/get-browser-globals/jshint.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ for (const key of globals) {
ret[key] = key.startsWith('on');
}

fs.writeFileSync('./browser_vars.json', `{ "jshint": \n\t${JSON.stringify(ret, null, '\t\t')},\n"my":\n\t{}\n}`);
fs.writeFileSync('./browser_vars.json', `{ "jshint": \n\t${JSON.stringify(ret, null, '\t\t')},\n"my":\n\n}`);
2 changes: 1 addition & 1 deletion update/get-browser-globals/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
- Open file `browser_vars.json`
- Paste yours current clipboard to the field `my` at the root of the project.
- run `npm run combine-browser`
- Copy and paste the result from the `browser_vars.json` to the field `browser` at the `globals.json`
- Copy and paste the result from the `result_browser_vars.json` to the field `browser` at the `globals.json`

0 comments on commit 6d26f17

Please sign in to comment.