UNPKG

1.54 kBJavaScriptView Raw
1/* Copyright (c) 2019, 2022, Oracle and/or its affiliates. */
2
3/******************************************************************************
4 *
5 * You may not use the identified files except in compliance with the Apache
6 * License, Version 2.0 (the "License.")
7 *
8 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0.
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * NAME
19 * prunebinaries.js
20 *
21 * DESCRIPTION
22 * Removes pre-built binaries for all other architectures.
23 * This can be used to reduce the footprint of a node-oracledb install.
24 *
25 * USAGE
26 * Invoke this from the top level directory.
27 * After an 'npm install oracledb' installs pre-built binaries, this file
28 * can be run with 'npm run prune'.
29 *
30 *****************************************************************************/
31
32'use strict';
33
34const fs = require('fs');
35const nodbUtil = require('../lib/util.js');
36
37const dir = nodbUtil.RELEASE_DIR;
38
39let re = new RegExp(nodbUtil.BINARY_FILE);
40
41try {
42 let f = fs.readdirSync(dir);
43 for (let i = 0; i < f.length; i++) {
44 if (!f[i].match(re) && (f[i].match(/oracledb.*\.node(-buildinfo.txt)*/))) {
45 fs.unlinkSync(dir + '/' + f[i]);
46 }
47 }
48} catch (err) {
49 console.error(err.message);
50}