Skip to content

Commit 643412c

Browse files
authored
Fix npm run docs:build on Windows environments (#16029)
* Fix `npm run docs:build` on Windows environments Windows environments do not support shebang (#!) scripts. This caused `npm run docs:build` to error when running it on Windows. The fix is to run `node docs/tool/update-data.js` instead of running `./docs/tool/update-data.js`. Similarly, running `node path/to/directory` can cause problems, so we update the docs:build task to use `node path/to/directory/index.js`. docs:build: Use the .js extension in the filename * docgen: Correctly handle docblocks with CRLF line endings This allows `npm run docs:build` to generate docs on Windows environments. * Use explicit paths as to prevent errors in Windows machines * Remove shebang notation in update-readmes.js so it works consistently in Windows machines. * Add comment
1 parent b95e865 commit 643412c

File tree

6 files changed

+18
-10
lines changed

6 files changed

+18
-10
lines changed

bin/update-readmes.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
#!/usr/bin/env node
2-
1+
/**
2+
* Node dependencies.
3+
*/
34
const { join } = require( 'path' );
45
const spawnSync = require( 'child_process' ).spawnSync;
56

docs/tool/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
const fs = require( 'fs' );
55
const { join } = require( 'path' );
6-
const { execSync } = require( 'child_process' );
6+
const { execFileSync } = require( 'child_process' );
77
const path = require( 'path' );
88

99
/**
@@ -15,7 +15,7 @@ const tocFileInput = path.resolve( __dirname, '../toc.json' );
1515
const manifestOutput = path.resolve( __dirname, '../manifest-devhub.json' );
1616

1717
// Update data files from code
18-
execSync( join( __dirname, 'update-data.js' ) );
18+
execFileSync( 'node', [ join( __dirname, 'update-data.js' ) ] );
1919

2020
// Process TOC file and generate manifest handbook
2121
fs.writeFileSync( manifestOutput, JSON.stringify( getRootManifest( tocFileInput ), undefined, '\t' ) );

docs/tool/update-data.js

100755100644
+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
#!/usr/bin/env node
2-
1+
/**
2+
* Node dependencies.
3+
*/
34
const { join } = require( 'path' );
45
const spawnSync = require( 'child_process' ).spawnSync;
56

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@
188188
"predev": "npm run check-engines",
189189
"dev": "npm run build:packages && concurrently \"wp-scripts start\" \"npm run dev:packages\"",
190190
"dev:packages": "node ./bin/packages/watch.js",
191-
"docs:build": "node ./docs/tool && node ./bin/update-readmes",
191+
"docs:build": "node ./docs/tool/index.js && node ./bin/update-readmes.js",
192192
"fixtures:clean": "rimraf \"packages/e2e-tests/fixtures/blocks/*.+(json|serialized.html)\"",
193193
"fixtures:server-registered": "docker-compose run -w /var/www/html/wp-content/plugins/gutenberg --rm wordpress ./bin/get-server-blocks.php > test/integration/full-content/server-registered.json",
194194
"fixtures:generate": "npm run fixtures:server-registered && cross-env GENERATE_MISSING_FIXTURES=y npm run test-unit",
@@ -233,10 +233,10 @@
233233
"wp-scripts lint-js"
234234
],
235235
"{docs/{toc.json,tool/*.js},packages/{*/README.md,*/src/{actions,selectors}.js,components/src/*/**/README.md}}": [
236-
"node ./docs/tool"
236+
"node ./docs/tool/index.js"
237237
],
238238
"packages/**/*.js": [
239-
"node ./bin/update-readmes"
239+
"node ./bin/update-readmes.js"
240240
]
241241
}
242242
}

packages/docgen/CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 1.2.1 (Unreleased)
2+
3+
### Bug Fixes
4+
5+
- Docblocks with CRLF endings are now parsed correctly.
6+
17
## 1.2.0 (2019-05-21)
28

39
### Enhancement

packages/docgen/src/get-jsdoc-from-token.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const getTypeAsString = require( './get-type-as-string' );
2020
module.exports = function( token ) {
2121
let jsdoc;
2222
const comments = getLeadingComments( token );
23-
if ( comments && comments.startsWith( '*\n' ) ) {
23+
if ( comments && /^\*\r?\n/.test( comments ) ) {
2424
jsdoc = doctrine.parse( comments, {
2525
unwrap: true,
2626
recoverable: true,

0 commit comments

Comments
 (0)