source: trip-planner-front/node_modules/node-gyp-build/bin.js@ 76712b2

Last change on this file since 76712b2 was e29cc2e, checked in by Ema <ema_spirova@…>, 3 years ago

primeNG components

  • Property mode set to 100644
File size: 1.9 KB
Line 
1#!/usr/bin/env node
2
3var proc = require('child_process')
4var os = require('os')
5var path = require('path')
6
7if (!buildFromSource()) {
8 proc.exec('node-gyp-build-test', function (err, stdout, stderr) {
9 if (err) {
10 if (verbose()) console.error(stderr)
11 preinstall()
12 }
13 })
14} else {
15 preinstall()
16}
17
18function build () {
19 var args = [os.platform() === 'win32' ? 'node-gyp.cmd' : 'node-gyp', 'rebuild']
20
21 try {
22 args = [
23 process.execPath,
24 path.join(require.resolve('node-gyp/package.json'), '..', require('node-gyp/package.json').bin['node-gyp']),
25 'rebuild'
26 ]
27 } catch (_) {}
28
29 proc.spawn(args[0], args.slice(1), { stdio: 'inherit' }).on('exit', function (code) {
30 if (code || !process.argv[3]) process.exit(code)
31 exec(process.argv[3]).on('exit', function (code) {
32 process.exit(code)
33 })
34 })
35}
36
37function preinstall () {
38 if (!process.argv[2]) return build()
39 exec(process.argv[2]).on('exit', function (code) {
40 if (code) process.exit(code)
41 build()
42 })
43}
44
45function exec (cmd) {
46 if (process.platform !== 'win32') {
47 var shell = os.platform() === 'android' ? 'sh' : '/bin/sh'
48 return proc.spawn(shell, ['-c', '--', cmd], {
49 stdio: 'inherit'
50 })
51 }
52
53 return proc.spawn(process.env.comspec || 'cmd.exe', ['/s', '/c', '"' + cmd + '"'], {
54 windowsVerbatimArguments: true,
55 stdio: 'inherit'
56 })
57}
58
59function buildFromSource () {
60 return hasFlag('--build-from-source') || process.env.npm_config_build_from_source === 'true'
61}
62
63function verbose () {
64 return hasFlag('--verbose') || process.env.npm_config_loglevel === 'verbose'
65}
66
67// TODO (next major): remove in favor of env.npm_config_* which works since npm
68// 0.1.8 while npm_config_argv will stop working in npm 7. See npm/rfcs#90
69function hasFlag (flag) {
70 if (!process.env.npm_config_argv) return false
71
72 try {
73 return JSON.parse(process.env.npm_config_argv).original.indexOf(flag) !== -1
74 } catch (_) {
75 return false
76 }
77}
Note: See TracBrowser for help on using the repository browser.