forked from daren.hsu/line_push
74 lines
1.9 KiB
JavaScript
74 lines
1.9 KiB
JavaScript
/*!
|
|
* @nuxt/cli v2.13.3 (c) 2016-2020
|
|
|
|
* - All the amazing contributors
|
|
* Released under the MIT License.
|
|
* Website: https://nuxtjs.org
|
|
*/
|
|
'use strict';
|
|
|
|
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
|
|
const index = require('./cli-index.js');
|
|
const path = require('path');
|
|
const path__default = _interopDefault(path);
|
|
require('@nuxt/config');
|
|
require('exit');
|
|
const utils = require('@nuxt/utils');
|
|
require('chalk');
|
|
require('std-env');
|
|
require('wrap-ansi');
|
|
require('boxen');
|
|
const consola = _interopDefault(require('consola'));
|
|
require('minimist');
|
|
require('hable');
|
|
require('fs');
|
|
require('execa');
|
|
|
|
const _export = {
|
|
name: 'export',
|
|
description: 'Export a static generated web application',
|
|
usage: 'export <dir>',
|
|
options: {
|
|
...index.common,
|
|
...index.locking,
|
|
'fail-on-error': {
|
|
type: 'boolean',
|
|
default: false,
|
|
description: 'Exit with non-zero status code if there are errors when exporting pages'
|
|
}
|
|
},
|
|
async run (cmd) {
|
|
const config = await cmd.getNuxtConfig({
|
|
dev: false,
|
|
target: utils.TARGETS.static,
|
|
_export: true
|
|
});
|
|
const nuxt = await cmd.getNuxt(config);
|
|
|
|
if (cmd.argv.lock) {
|
|
await cmd.setLock(await index.createLock({
|
|
id: 'export',
|
|
dir: nuxt.options.generate.dir,
|
|
root: config.rootDir
|
|
}));
|
|
}
|
|
|
|
const generator = await cmd.getGenerator(nuxt);
|
|
await nuxt.server.listen(0);
|
|
|
|
const { errors } = await generator.generate({
|
|
init: true,
|
|
build: false
|
|
});
|
|
|
|
await nuxt.close();
|
|
if (cmd.argv['fail-on-error'] && errors.length > 0) {
|
|
throw new Error('Error exporting pages, exiting with non-zero code')
|
|
}
|
|
consola.info('Ready to run `nuxt serve` or deploy `' + path__default.basename(nuxt.options.generate.dir) + '/` directory');
|
|
}
|
|
};
|
|
|
|
exports.default = _export;
|