Skip to content

Commit 89efba2

Browse files
committed
📦 install server binary
1 parent 57a8e45 commit 89efba2

File tree

4 files changed

+45
-7
lines changed

4 files changed

+45
-7
lines changed

.babelrc

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,21 @@
77
}
88
}
99
]
10+
],
11+
"plugins": [
12+
"transform-class-properties",
13+
[
14+
"shebang",
15+
{
16+
"replacement": "#!/usr/bin/env node",
17+
"force": true
18+
}
19+
]
20+
],
21+
"ignore": [
22+
"**/*.test.js",
23+
"**/testSpi.js",
24+
"**/setupTests.js",
25+
"testing/**"
1026
]
11-
}
27+
}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.idea
22
node_modules
33
coverage
4+
lib
45

56
*.lock

package.json

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@
33
"version": "0.1.3",
44
"description": "A NodeJS server for controlling APA102/SK9822/WS281X LED strips over OPC",
55
"main": "src/main.js",
6-
"private": false,
6+
"preinstall": "npm install --ignore-scripts && babel src --out-dir lib",
7+
"bin": {
8+
"telecortex-server": "lib/main.js",
9+
"@js-telecortex-2/js-telecortex-2-server": "lib/main.js"
10+
},
11+
"publishConfig": {
12+
"access": "public"
13+
},
714
"scripts": {
815
"test": "jest --watch --coverage",
916
"test-ci": "jest --ci --coverage",
@@ -27,6 +34,8 @@
2734
"@babel/node": "^7.4.5",
2835
"@babel/preset-env": "^7.4.5",
2936
"babel-loader": "^8.0.6",
37+
"babel-plugin-shebang": "^1.0.0",
38+
"babel-plugin-transform-class-properties": "^6.24.1",
3039
"codecov": "^3.7.2",
3140
"eslint": "^5.16.0",
3241
"eslint-config-airbnb-base": "^13.1.0",
@@ -43,6 +52,18 @@
4352
"webpack": "^4.33.0",
4453
"webpack-cli": "^3.3.2"
4554
},
55+
"keywords": [
56+
"open pixel control",
57+
"opc",
58+
"raspberry pi",
59+
"apa102",
60+
"sk9822",
61+
"ws2811",
62+
"ws2812",
63+
"ws281x",
64+
"neopixel",
65+
"dotstar"
66+
],
4667
"husky": {
4768
"hooks": {
4869
"pre-commit": "lint-staged"

src/main.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ const unpackYargsGroup = (options, group, args) => {
8585
]);
8686
};
8787

88-
const parseArgs = () => {
88+
const parseArgs = args => {
8989
const spiOptions = {
9090
clockSpeed: {
9191
description: 'SPI Clock speed to use for all devices',
@@ -154,17 +154,17 @@ const parseArgs = () => {
154154
.options(groupYargsOptions(pbxOptions, 'pbx'))
155155
.help()
156156
.alias('help', 'h')
157-
.parse(process.argv);
157+
.parse(args);
158158
return {
159159
...result,
160160
...unpackYargsGroup(spiOptions, 'spi', result),
161161
...unpackYargsGroup(pbxOptions, 'pbx', result)
162162
};
163163
};
164164

165-
const server = () => {
165+
export const server = args => {
166166
// const config = { ...SERVER_CONF, ...parseArgs() };
167-
const config = parseArgs();
167+
const config = parseArgs(args);
168168
console.log('config: ', config);
169169
const { port, devType, middlewareProtocol, transportProtocol } = config;
170170
// TODO: flick status led
@@ -185,4 +185,4 @@ const server = () => {
185185
serverFn(context);
186186
};
187187

188-
server();
188+
server(process.argv);

0 commit comments

Comments
 (0)