UNPKG

496 BJavaScriptView Raw
1#!/usr/bin/env node
2
3const pkgUp = require('pkg-up');
4const { readFile, writeFile } = require('jsonfile');
5
6const 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
15const rename = async name => {
16 const initial = await packageJson.read();
17
18 const temp = { ...initial, name };
19 await packageJson.write(temp);
20};
21
22rename(...process.argv.slice(2, 3));