|
| 1 | +/** |
| 2 | +* @license Apache-2.0 |
| 3 | +* |
| 4 | +* Copyright (c) 2019 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 | +'use strict'; |
| 20 | + |
| 21 | +// MODULES // |
| 22 | + |
| 23 | +var fs = require( 'fs' ); |
| 24 | +var path = require( 'path' ); |
| 25 | +var flattenObject = require( '@stdlib/utils/flatten-object' ); |
| 26 | +var objectKeys = require( '@stdlib/utils/keys' ); |
| 27 | +var exists = require( '@stdlib/fs/exists' ).sync; |
| 28 | +var version = require( './../../../../package.json' ).version; |
| 29 | +var tree = require( '../public/assets/v'+version+'/package_tree.json' ); |
| 30 | + |
| 31 | + |
| 32 | +// MAIN // |
| 33 | + |
| 34 | +var docsPath = path.resolve( __dirname, '..', 'public', 'assets', 'v'+version ); |
| 35 | + |
| 36 | +// Create object with information on each package about whether it has benchmarks and tests: |
| 37 | +var paths = flattenObject( tree, { |
| 38 | + 'delimiter': '/' |
| 39 | +}); |
| 40 | + |
| 41 | +var keys = objectKeys( paths ); |
| 42 | + |
| 43 | +for ( var i = 0; i < keys.length; i++ ) { |
| 44 | + console.log( path.join( docsPath, '@stdlib', keys[ i ], 'test.html' ) ); |
| 45 | + console.log( exists( path.join( docsPath, '@stdlib', keys[ i ], 'test.html' ) ) ) |
| 46 | + paths[ keys[ i ] ] = { |
| 47 | + 'benchmark': exists( path.join( docsPath, '@stdlib', keys[ i ], 'benchmark.html' ) ), |
| 48 | + 'test': exists( path.join( docsPath, '@stdlib', keys[ i ], 'test.html' ) ) |
| 49 | + } |
| 50 | +} |
| 51 | +fs.writeFileSync( path.join( docsPath, 'package_resources.json' ), JSON.stringify( paths ) ); |
0 commit comments