浏览代码

Fix: NPM script docs ignores --skip-api option.

Maciej Gołaszewski 8 年之前
父节点
当前提交
b2b59917fa
共有 1 个文件被更改,包括 24 次插入18 次删除
  1. 24 18
      scripts/docs/build-docs.js

+ 24 - 18
scripts/docs/build-docs.js

@@ -16,30 +16,36 @@ const skipLiveSnippets = process.argv.includes( '--skip-snippets' );
 const skipApi = process.argv.includes( '--skip-api' );
 const production = process.argv.includes( '--production' );
 
-if ( skipApi ) {
-	const fs = require( 'fs' );
-	const apiJsonPath = './docs/api/output.json';
+buildDocs();
 
-	if ( fs.existsSync( apiJsonPath ) ) {
-		fs.unlinkSync( apiJsonPath );
-	}
+function buildDocs() {
+	if ( skipApi ) {
+		const fs = require( 'fs' );
+		const apiJsonPath = './docs/api/output.json';
 
-	runUmberto( {
-		skipLiveSnippets,
-		skipApi,
-		production
-	} ).then( () => process.exit() );
-}
+		if ( fs.existsSync( apiJsonPath ) ) {
+			fs.unlinkSync( apiJsonPath );
+		}
 
-// Simple way to reuse existing api/output.json:
-// return Promise.resolve()
-buildApiDocs()
-	.then( () => {
-		return runUmberto( {
+		runUmberto( {
 			skipLiveSnippets,
+			skipApi,
 			production
+		} ).then( () => process.exit() );
+
+		return;
+	}
+
+	// Simple way to reuse existing api/output.json:
+	// return Promise.resolve()
+	buildApiDocs()
+		.then( () => {
+			return runUmberto( {
+				skipLiveSnippets,
+				production
+			} );
 		} );
-	} );
+}
 
 function runUmberto( options ) {
 	assertIsInstalled( 'umberto' );