From 5f3d3cb36f9acd4a7c8c84cf3c515285dd725a73 Mon Sep 17 00:00:00 2001 From: endiliey Date: Fri, 17 May 2019 15:24:27 +0800 Subject: [PATCH] centralize --- packages/docusaurus-1.x/lib/server/generate.js | 13 +++++-------- packages/docusaurus-1.x/lib/server/readMetadata.js | 3 ++- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/packages/docusaurus-1.x/lib/server/generate.js b/packages/docusaurus-1.x/lib/server/generate.js index a19a4fbae36c..41192fdcd8e4 100644 --- a/packages/docusaurus-1.x/lib/server/generate.js +++ b/packages/docusaurus-1.x/lib/server/generate.js @@ -6,6 +6,11 @@ */ async function execute() { + const commander = require('commander'); + commander + .option('--skip-image-compression') + .option('--skip-next-release') + .parse(process.argv); require('../write-translations.js'); const metadataUtils = require('./metadataUtils'); const blog = require('./blog'); @@ -30,20 +35,12 @@ async function execute() { const sep = path.sep; const escapeStringRegexp = require('escape-string-regexp'); const {renderToStaticMarkupWithDoctype} = require('./renderUtils'); - const commander = require('commander'); const imagemin = require('imagemin'); const imageminJpegtran = require('imagemin-jpegtran'); const imageminOptipng = require('imagemin-optipng'); const imageminSvgo = require('imagemin-svgo'); const imageminGifsicle = require('imagemin-gifsicle'); - commander - .option('--skip-image-compression') - .option('--skip-next-release') - .parse(process.argv); - - process.env.SKIP_NEXT_RELEASE = commander.skipNextRelease; - // create the folder path for a file if it does not exist, then write the file function writeFileAndCreateFolder(file, content) { mkdirp.sync(path.dirname(file)); diff --git a/packages/docusaurus-1.x/lib/server/readMetadata.js b/packages/docusaurus-1.x/lib/server/readMetadata.js index 7c58d37fec03..71b9410044a5 100644 --- a/packages/docusaurus-1.x/lib/server/readMetadata.js +++ b/packages/docusaurus-1.x/lib/server/readMetadata.js @@ -10,6 +10,7 @@ const CWD = process.cwd(); const path = require('path'); const fs = require('fs'); const glob = require('glob'); +const program = require('commander'); const metadataUtils = require('./metadataUtils'); @@ -55,7 +56,7 @@ function getDocsPath() { } function shouldGenerateNextReleaseDocs() { - return !(env.versioning.enabled && process.env.SKIP_NEXT_RELEASE); + return !(env.versioning.enabled && program.skipNextRelease); } // returns map from id to object containing sidebar ordering info