Skip to content

Commit 8c7185f

Browse files
committed
build: wrap alias extraction in try-catch block
1 parent 4f2310d commit 8c7185f

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

lib/node_modules/@stdlib/_tools/scripts/publish_packages.js

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,18 +1063,21 @@ function publish( pkg, clbk ) {
10631063
command = 'STDLIB_INPUT_SOURCE_MAP=\'./dist/index.js.map\' STDLIB_PKG=\'@stdlib/'+distPkg+'\' '+jscodeshift+' ./dist/index.js -t '+join( __dirname, 'transform.js' );
10641064
debug( 'Executing command: %s', command );
10651065
shell( command, opts );
1066-
1067-
// Extract the alias from the Typescript definition file (after `export =` but before the semicolon):
1068-
command = 'grep -oP \'(?<=export = ).*?(?=;)\' docs/types/index.d.ts';
1069-
alias = trim( shell( command, opts ).toString() );
1070-
1071-
// Create the contents of a `index.d.ts` file in `dist` subdirectory that reexports `docs/types/index.d.ts` (we don't want to duplicate type definitions, so we just reexport them):
1072-
contents = [
1073-
'/// <reference path="../docs/types/index.d.ts" />',
1074-
'import '+alias+' from \'../docs/types/index\';',
1075-
'export = '+alias+';'
1076-
].join( '\n' );
1077-
writeFileSync( join( dist, 'dist', 'index.d.ts' ), contents );
1066+
try {
1067+
// Extract the alias from the Typescript definition file (after `export =` but before the semicolon):
1068+
command = 'grep -oP \'(?<=export = ).*?(?=;)\' docs/types/index.d.ts';
1069+
alias = trim( shell( command, opts ).toString() );
1070+
1071+
// Create the contents of a `index.d.ts` file in `dist` subdirectory that reexports `docs/types/index.d.ts` (we don't want to duplicate type definitions, so we just reexport them):
1072+
contents = [
1073+
'/// <reference path="../docs/types/index.d.ts" />',
1074+
'import '+alias+' from \'../docs/types/index\';',
1075+
'export = '+alias+';'
1076+
].join( '\n' );
1077+
writeFileSync( join( dist, 'dist', 'index.d.ts' ), contents );
1078+
} catch ( error ) {
1079+
debug( 'Encountered an error when attempting to extract the alias from the Typescript definition file: %s', error.message );
1080+
}
10781081

10791082
if ( flags[ 'skip-upload' ] ) {
10801083
return invokeCallback( null, 'skipped' );

0 commit comments

Comments
 (0)