Skip to content

Commit 59dde40

Browse files
committed
Replace jq usage with Node.js script
1 parent 1e1aaa6 commit 59dde40

File tree

2 files changed

+53
-8
lines changed

2 files changed

+53
-8
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2021 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
/* eslint-disable node/no-sync, no-console */
20+
21+
'use strict';
22+
23+
// MODULES //
24+
25+
var readFileSync = require( 'fs' ).readFileSync;
26+
var join = require( 'path' ).join;
27+
28+
29+
// MAIN //
30+
31+
// Path to the root directory:
32+
var dir = join( __dirname, '..', '..' );
33+
34+
// File path to the root package.json file:
35+
var fpath = join( dir, 'package.json' );
36+
37+
// Read the root package.json file:
38+
var pkg = JSON.parse( readFileSync( fpath, 'utf8' ) );
39+
40+
// Extract list of dependencies from the root package.json file and write newline-delimited list of `@stdlib` dependencies to stdout:
41+
var keys = Object.keys( pkg.dependencies );
42+
var key;
43+
var i;
44+
45+
for ( i = 0; i < keys.length; i++ ) {
46+
key = keys[ i ];
47+
if ( key.startsWith( '@stdlib' ) ) {
48+
console.log( key );
49+
}
50+
}

tools/scripts/npm_publish

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -417,16 +417,11 @@ update_version() {
417417
# Updates the `@stdlib` dependencies in the root package.json to their latest versions.
418418
update_internal_dependencies() {
419419
echo 'Updating `@stdlib` dependency versions...' >&2
420-
echo 'Getting list of `@stdlib` dependencies...' >&2
420+
echo 'Getting list of `@stdlib` dependencies from package.json file...' >&2
421421
dependencies="$(
422-
jq -r '
423-
.dependencies |
424-
to_entries |
425-
map(select(.key | startswith("@stdlib/"))) |
426-
map(.key) |
427-
join(" ")
428-
' "${package_json}"
422+
node list_stdlib_dependencies.js
429423
)"
424+
echo "Found ${dependencies} @stdlib dependencies." >&2
430425
if [[ "$?" -ne 0 ]]; then
431426
echo '' >&2
432427
echo 'Error: unexpected error. Encountered an error when getting list of `@stdlib` dependencies.' >&2

0 commit comments

Comments
 (0)