Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 11 additions & 15 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ function printHeader() {
logger.log(` v${CLI_VERSION}`);
}

function handleError(error) {
logger.error(error.message);
process.exitCode = 1;
}

program
.allowUnknownOption()
.usage(' <command>');
Expand All @@ -49,9 +54,7 @@ program
.then(() => {
logger.info('Initialization success.');
})
.catch((error) => {
logger.error(error.message);
});
.catch(handleError);
});

program
Expand All @@ -68,7 +71,7 @@ program
try {
rootFolder = cliUtil.findRootFolder(userSpecifiedRoot);
} catch (err) {
logger.error(err.message);
handleError(err);
}
const logsFolder = path.join(rootFolder, '_markbind/logs');
const outputFolder = path.join(rootFolder, '_site');
Expand Down Expand Up @@ -159,9 +162,7 @@ program
logger.info('Press CTRL+C to stop ...');
});
})
.catch((error) => {
logger.error(error.message);
});
.catch(handleError);
});

program
Expand All @@ -176,10 +177,7 @@ program
.then(() => {
logger.info('Deployed!');
})
.catch((err) => {
logger.error(err.message);
process.exitCode = 1;
});
.catch(handleError);
printHeader();
});

Expand All @@ -196,7 +194,7 @@ program
try {
rootFolder = cliUtil.findRootFolder(userSpecifiedRoot);
} catch (err) {
logger.error(err.message);
handleError(err);
}
const defaultOutputRoot = path.join(rootFolder, '_site');
const outputFolder = output ? path.resolve(process.cwd(), output) : defaultOutputRoot;
Expand All @@ -206,9 +204,7 @@ program
.then(() => {
logger.info('Build success!');
})
.catch((error) => {
logger.error(error.message);
});
.catch(handleError);
});

program.parse(process.argv);
Expand Down