Skip to content

Commit 1a44832

Browse files
authored
Fix windows installation (#1098)
Fixes #1050. Previously, it was not possible to install src-cli via npm on Windows. It was also not possible to publish the npm package on Windows. This PR fixes both problems. The second problem had to be solved so I could manually test the fix for this PR.:
1 parent dcc02b2 commit 1a44832

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

npm-distribution/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules/
22
src
33
LICENSE
4+
README.md

npm-distribution/copy-files.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const fs = require('fs')
2+
const path = require('path')
3+
4+
const licensePath = path.join(__dirname, '..', 'LICENSE')
5+
const readmePath = path.join(__dirname, '..', 'README.md')
6+
7+
fs.copyFileSync(licensePath, path.join(__dirname, 'LICENSE'))
8+
fs.copyFileSync(readmePath, path.join(__dirname, 'README.md'))

npm-distribution/install.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,12 @@ get(assetURL, (response) => {
5656
}
5757
response
5858
.pipe(zlib.createGunzip())
59-
.pipe(tar.x({ filter: (x) => x === "src" }))
60-
.addListener("close", () => fs.chmodSync(executableName, "755"));
61-
});
59+
.pipe(tar.x({ filter: (x) => x === executableName }))
60+
.addListener("close", () => {
61+
if (process.platform !== 'win32') {
62+
fs.chmodSync(executableName, "755");
63+
}
64+
});});
6265

6366
// Follow redirects.
6467
function get(url, callback) {

npm-distribution/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"license": "Apache-2.0",
88
"scripts": {
99
"install": "node install.js",
10-
"prepack": "cp ../LICENSE . && cp ../README.md ."
10+
"prepack": "node copy-files.js"
1111
},
1212
"main": "src.js",
1313
"bin": {

0 commit comments

Comments
 (0)