1 | #!/usr/bin/env node
|
2 |
|
3 | const pkgUp = require('pkg-up');
|
4 | const { readFile, writeFile } = require('jsonfile');
|
5 |
|
6 | const packageJson = {
|
7 | async read() {
|
8 | return pkgUp(__dirname).then(l => readFile(l));
|
9 | },
|
10 | async write(json) {
|
11 | return pkgUp(__dirname).then(l => writeFile(l, json, { spaces: 2 }));
|
12 | },
|
13 | };
|
14 |
|
15 | const rename = async name => {
|
16 | const initial = await packageJson.read();
|
17 |
|
18 | const temp = { ...initial, name };
|
19 | await packageJson.write(temp);
|
20 | };
|
21 |
|
22 | rename(...process.argv.slice(2, 3));
|