Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a3b384f

Browse files
[pkg] refactor script for linux
Signed-off-by: Eric Wang <skygragon@gmail.com>
1 parent c957d78 commit a3b384f

File tree

3 files changed

+39
-22
lines changed

3 files changed

+39
-22
lines changed

‎bin/pkg

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,19 @@
1-
#!/bin/bash
1+
#!/usr/bin/env node
22

3-
plugins="company cookie.chrome cookie.firefox cpp.lint cpp.run github leetcode.cn lintcode solution.discuss"
3+
const arch = require('os').arch();
4+
var os = process.platform;
5+
const ver = process.versions.node.split('.')[0];
46

5-
for plugin in $plugins; do
6-
echo "[$plugin]"
7-
./bin/leetcode ext -i $plugin
8-
done
7+
var bin = './bin/pkg.sh';
8+
var args = [arch, os, ver];
99

10-
ver=`node -v | sed 's/^v//' | awk -F. '{print 1ドル}'`
11-
case `uname` in
12-
Linux) os=linux ;;
13-
Darwin) os=macos ;;
14-
*) echo "OS not supported!" && exit 1
15-
esac
16-
case `uname -m` in
17-
x86_64) arch=x64 ;;
18-
i?86) arch=x32 ;;
19-
*) echo "Arch not supported!" && exit 1
20-
esac
10+
if (os === 'darwin') {
11+
args[1] = 'macos';
12+
} else if (os === 'win32') {
13+
bin = 'cmd.exe';
14+
args = ['/c', 'pkg.bat'].concat(args);
15+
}
2116

22-
mkdir -p dist/
23-
rm -rf dist/*
24-
find node_modules -name "*.node" -exec cp {} dist/ \;
25-
npm run pkg -- node$ver-$os-$arch
26-
tar zcvf leetcode-cli.$os.tar.gz dist/
17+
var proc = require('child_process').spawn(bin, args);
18+
proc.stdout.on('data', x => console.log(x.toString().trimRight('\n')));
19+
proc.stderr.on('data', x => console.log(x.toString().trimRight('\n')));

‎bin/pkg.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
3+
arch=1ドル
4+
os=2ドル
5+
ver=3ドル
6+
7+
plugins="company cookie.chrome cookie.firefox cpp.lint cpp.run github leetcode.cn lintcode solution.discuss"
8+
9+
for plugin in $plugins; do
10+
echo "[$plugin]"
11+
#./bin/leetcode ext -i $plugin
12+
done
13+
14+
DIST=./dist
15+
mkdir -p $DIST
16+
rm -rf $DIST/*
17+
18+
find node_modules -name "*.node" -exec cp {} $DIST \;
19+
npm run pkg -- node$ver-$os-$arch
20+
21+
FILE=leetcode-cli.node$ver.$os.$arch.tar.gz
22+
tar zcvf $FILE $DIST
23+
ls -al $FILE

‎package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
"mocha": "5.2.0",
7272
"nock": "10.0.2",
7373
"nyc": "13.1.0",
74+
"pkg": "^4.3.4",
7475
"rewire": "4.0.1"
7576
}
7677
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /