-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Expand file tree
/
Copy pathcreateBin
More file actions
executable file
·38 lines (31 loc) · 923 Bytes
/
createBin
File metadata and controls
executable file
·38 lines (31 loc) · 923 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env node
const fs = require('fs');
const os = require('os');
const path = require('path');
const verbose = process.argv.includes('-v');
const source = path.join(__dirname, 'build/src/cli.js');
const targetDir = path.join(__dirname, 'bin');
const target = path.join(targetDir, 'wallet');
if (!fs.existsSync(targetDir)) {
fs.mkdirSync(targetDir);
}
try {
const lstat = fs.lstatSync(target);
if (lstat.isSymbolicLink() || lstat.isFile()) {
verbose && console.info('Removing stale file:', target);
fs.rmSync(target);
}
} catch (e) {
verbose && console.info('No stale file to remove:', e.message);
// Ignore errors if the file does not exist
}
try {
fs.chmodSync(source, '755');
} catch (e) {
if (os.platform() !== 'win32') {
throw e;
}
// Ignore errors on Windows
}
verbose && console.info('Creating symlink: ', source, ' -> ', target);
fs.symlinkSync(source, target, 'file');