Skip to content

Commit f6b4155

Browse files
committed
feat(install): use --force
1 parent dadfac8 commit f6b4155

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1781
-3666
lines changed

lib/init.js

+15-9
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,24 @@ export default async function initMain(progname, rawArgs, priv) {
66
const { console, error } = priv;
77
const {
88
_: args,
9-
} = parseArgs(rawArgs);
9+
force,
10+
} = parseArgs(rawArgs, { boolean: ['force'] });
1011

1112
if (args.length !== 1) {
12-
error(`you must specify exactly one DIR`);
13+
return error(`you must specify exactly one DIR`);
1314
}
1415
const [DIR] = args;
1516

1617
const { mkdir, stat, lstat, symlink, readdir, readFile, writeFile } = fs.promises;
1718

1819
console.log(`initializing ${DIR}`);
19-
await mkdir(DIR);
20+
try {
21+
await mkdir(DIR);
22+
} catch (e) {
23+
if (!force) {
24+
throw e;
25+
}
26+
}
2027

2128
const templateDir = `${__dirname}/../template`;
2229
const writeTemplate = async stem => {
@@ -38,12 +45,11 @@ export default async function initMain(progname, rawArgs, priv) {
3845
try {
3946
target = await stat(`${DIR}${stem}`);
4047
} catch (e) {}
41-
if (target) {
42-
return;
43-
}
4448
if (st.isDirectory()) {
45-
console.log(`mkdir ${DIR}${stem}`);
46-
await mkdir(`${DIR}${stem}`);
49+
if (!target) {
50+
console.log(`mkdir ${DIR}${stem}`);
51+
await mkdir(`${DIR}${stem}`);
52+
}
4753
await recursiveTemplate(templateDir, `${stem}`)
4854
} else {
4955
console.log(`write ${DIR}${stem}`);
@@ -53,5 +59,5 @@ export default async function initMain(progname, rawArgs, priv) {
5359
};
5460
await recursiveTemplate(templateDir);
5561

56-
console.log(chalk.bold.yellow(`Done initializing; you should 'cd ${DIR} && ${progname} install'`));
62+
console.log(chalk.bold.yellow(`Done initializing`));
5763
}

lib/install.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export default async function installMain(progname, rawArgs, priv) {
3535
pspawn('npm', ['install'], { cwd: '.agservers', stdio: 'inherit' });
3636

3737
const iRets = await Promise.all([
38-
pspawn(pm, ['install'], { cwd: 'ui', stdio: 'inherit' }),
38+
// pspawn(pm, ['install'], { cwd: 'ui', stdio: 'inherit' }),
3939
pspawn(pm, ['install'], { cwd: 'api', stdio: 'inherit' }),
4040
pspawn(pm, ['install'], { cwd: 'contract', stdio: 'inherit' }),
4141
goCmd,

lib/start.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export default async function startMain(progname, rawArgs, priv) {
4949
console.log(chalk.green('linking html directories'));
5050
const dappHtml = '.agservers/solo/dapp-html';
5151
const htmlWallet = '.agservers/solo/html/wallet';
52-
await Promise.all([fs.unlink(dappHtml).catch(() => {}), fs.unlink(htmlWallet).catch(() => {})]);
52+
// await Promise.all([fs.unlink(dappHtml).catch(() => {}), fs.unlink(htmlWallet).catch(() => {})]);
5353
await Promise.all([fs.symlink('../../ui/build', dappHtml).catch(() => {}),
5454
fs.symlink('../../../.agwallet', htmlWallet).catch(() => {})]);
5555

0 commit comments

Comments
 (0)