Skip to content

Commit

Permalink
feat: add spread
Browse files Browse the repository at this point in the history
  • Loading branch information
Dave Garwacke committed May 27, 2018
1 parent a929c96 commit f2e5dd3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
21 changes: 12 additions & 9 deletions bin/explainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const command = process.argv[2];

const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
output: process.stdout,
});

const writeFile = util.promisify(fs.writeFile);
Expand All @@ -19,8 +19,11 @@ const access = util.promisify(fs.access);

const stringify = exp => JSON.stringify(exp, null, 2);
const getPackageName = (deps, key) => `${key}@${deps[key]}`;
const getDeps = ({ dependencies, devDependencies, peerDependencies }) =>
Object.assign({}, dependencies, devDependencies, peerDependencies);
const getDeps = ({ dependencies, devDependencies, peerDependencies }) => ({
...dependencies,
...devDependencies,
...peerDependencies,
});
const keysDiff = (a, b) =>
Math.abs(Object.keys(a).length - Object.keys(b).length);

Expand All @@ -30,7 +33,7 @@ const COLORS = {
green: "[32m",
yellow: "[33m",
blue: "[34m",
magenta: "[35m"
magenta: "[35m",
};

const log = (color = COLORS.reset, title, ...strs) => {
Expand Down Expand Up @@ -78,8 +81,8 @@ async function getPkgData() {
return {
...dataPkg,
explainer: dataPkg.explainer || {
explainer: "Explains our choices"
}
explainer: "Explains our choices",
},
};
}

Expand Down Expand Up @@ -110,7 +113,7 @@ async function update() {
const deps = getDeps(dataPkg);

const updated = Object.keys(deps).reduce((memo, key) => {
return Object.assign({}, memo, { [key]: dataPkg.explainer[key] || "" });
return { ...memo, [key]: dataPkg.explainer[key] || "" };
}, explainer);

await writeToPkg({ ...dataPkg, explainer: updated });
Expand All @@ -134,8 +137,8 @@ async function add() {
...dataPkg,
explainer: {
...dataPkg.explainer,
[dep]: description
}
[dep]: description,
},
})
);
rl.close();
Expand Down
9 changes: 0 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,3 @@
# yarn lockfile v1


node-bin-setup@^1.0.0:
version "1.0.6"
resolved "https://registry.npmjs.org/node-bin-setup/-/node-bin-setup-1.0.6.tgz#4b5c9bb937ece702d7069b36ca78af4684677528"

node@8:
version "8.11.1"
resolved "https://registry.npmjs.org/node/-/node-8.11.1.tgz#565fdea7b35f0bf7eebefac6c2b88d34141dd0eb"
dependencies:
node-bin-setup "^1.0.0"

0 comments on commit f2e5dd3

Please sign in to comment.