mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-06 02:08:55 +02:00
chore: prettier & lint
This commit is contained in:
parent
1150c45f9b
commit
1d99c224c0
1 changed files with 65 additions and 65 deletions
130
bin/munseo.js
130
bin/munseo.js
|
@ -1,65 +1,65 @@
|
||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
const chalk = require('chalk');
|
const chalk = require('chalk');
|
||||||
const semver = require('semver');
|
const semver = require('semver');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const program = require('commander');
|
const program = require('commander');
|
||||||
const {build, init, start} = require('../lib');
|
const {build, init, start} = require('../lib');
|
||||||
const requiredVersion = require('../package.json').engines.node;
|
const requiredVersion = require('../package.json').engines.node;
|
||||||
|
|
||||||
if (!semver.satisfies(process.version, requiredVersion)) {
|
if (!semver.satisfies(process.version, requiredVersion)) {
|
||||||
console.log(
|
console.log(
|
||||||
chalk.red(`\nMinimum node version not met :)`) +
|
chalk.red(`\nMinimum node version not met :)`) +
|
||||||
chalk.yellow(
|
chalk.yellow(
|
||||||
`\nYou are using Node ${
|
`\nYou are using Node ${
|
||||||
process.version
|
process.version
|
||||||
}, Requirement: Node ${requiredVersion}.\n`
|
}, Requirement: Node ${requiredVersion}.\n`
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
function wrapCommand(fn) {
|
function wrapCommand(fn) {
|
||||||
return (...args) =>
|
return (...args) =>
|
||||||
fn(...args).catch(err => {
|
fn(...args).catch(err => {
|
||||||
console.error(chalk.red(err.stack));
|
console.error(chalk.red(err.stack));
|
||||||
process.exitCode = 1;
|
process.exitCode = 1;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
program
|
program
|
||||||
.version(require('../package.json').version)
|
.version(require('../package.json').version)
|
||||||
.usage('<command> [options]');
|
.usage('<command> [options]');
|
||||||
|
|
||||||
program
|
program
|
||||||
.command('build [siteDir]')
|
.command('build [siteDir]')
|
||||||
.description('Build website')
|
.description('Build website')
|
||||||
.option(
|
.option(
|
||||||
'-sic, --skip-image-compression <skipImageCompression>',
|
'-sic, --skip-image-compression <skipImageCompression>',
|
||||||
'Skip compression of image assets (default: false)'
|
'Skip compression of image assets (default: false)'
|
||||||
)
|
)
|
||||||
.action((siteDir = '.', {skipImageCompression}) => {
|
.action((siteDir = '.', {skipImageCompression}) => {
|
||||||
wrapCommand(build)(path.resolve(siteDir), {skipImageCompression});
|
wrapCommand(build)(path.resolve(siteDir), {skipImageCompression});
|
||||||
});
|
});
|
||||||
|
|
||||||
program
|
program
|
||||||
.command('init [projectDir]')
|
.command('init [projectDir]')
|
||||||
.description('Initialize website')
|
.description('Initialize website')
|
||||||
.action((projectDir = '.') => {
|
.action((projectDir = '.') => {
|
||||||
wrapCommand(init)(path.resolve(projectDir));
|
wrapCommand(init)(path.resolve(projectDir));
|
||||||
});
|
});
|
||||||
|
|
||||||
program
|
program
|
||||||
.command('start [siteDir]')
|
.command('start [siteDir]')
|
||||||
.description('Start development server')
|
.description('Start development server')
|
||||||
.option('-p, --port <port>', 'use specified port (default: 3000)')
|
.option('-p, --port <port>', 'use specified port (default: 3000)')
|
||||||
.option('-nw, --no-watch <noWatch>', 'disable live reload (default: false)')
|
.option('-nw, --no-watch <noWatch>', 'disable live reload (default: false)')
|
||||||
.action((siteDir = '.', {port, noWatch}) => {
|
.action((siteDir = '.', {port, noWatch}) => {
|
||||||
wrapCommand(start)(path.resolve(siteDir), {port, noWatch});
|
wrapCommand(start)(path.resolve(siteDir), {port, noWatch});
|
||||||
});
|
});
|
||||||
|
|
||||||
program.parse(process.argv);
|
program.parse(process.argv);
|
||||||
|
|
||||||
if (!process.argv.slice(2).length) {
|
if (!process.argv.slice(2).length) {
|
||||||
program.outputHelp();
|
program.outputHelp();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue