@getgauge/cli 1.5.0 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -5
- package/src/index.js +22 -5
- package/src/install.js +6 -1
package/package.json
CHANGED
|
@@ -24,12 +24,12 @@
|
|
|
24
24
|
},
|
|
25
25
|
"homepage": "https://github.com/getgauge/gauge#readme",
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"chai": "^4.
|
|
28
|
-
"mocha": "^
|
|
29
|
-
"sinon": "^
|
|
27
|
+
"chai": "^4.3.7",
|
|
28
|
+
"mocha": "^10.2.0",
|
|
29
|
+
"sinon": "^15.2.0"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"
|
|
32
|
+
"adm-zip": "^0.5.10"
|
|
33
33
|
},
|
|
34
|
-
"version": "1.5.
|
|
34
|
+
"version": "1.5.2"
|
|
35
35
|
}
|
package/src/index.js
CHANGED
|
@@ -4,19 +4,35 @@
|
|
|
4
4
|
|
|
5
5
|
const install = require("./install"),
|
|
6
6
|
path = require("path"),
|
|
7
|
-
|
|
7
|
+
AdmZip = require('adm-zip'),
|
|
8
8
|
https = require('https'),
|
|
9
9
|
packageJsonPath = path.join(__dirname, "..", "package.json"),
|
|
10
10
|
binPath = "./bin";
|
|
11
11
|
|
|
12
|
+
var extractZipArchive = function(buffer) {
|
|
13
|
+
return new Promise(function(resolve, reject) {
|
|
14
|
+
try {
|
|
15
|
+
const zip = new AdmZip(buffer);
|
|
16
|
+
zip.extractAllTo(path.normalize(binPath), true, true);
|
|
17
|
+
resolve();
|
|
18
|
+
} catch (err) {
|
|
19
|
+
reject(new Error(`Failed to extract archive from buffer: ${err.message}`));
|
|
20
|
+
}
|
|
21
|
+
})
|
|
22
|
+
}
|
|
23
|
+
|
|
12
24
|
var downloadFollowingRedirect = function(url, resolve, reject) {
|
|
13
25
|
https.get(url, { headers: { 'accept-encoding': 'gzip,deflate' } }, res => {
|
|
14
26
|
if (res.statusCode >= 300 && res.statusCode < 400) {
|
|
15
|
-
downloadFollowingRedirect(res.headers.location,
|
|
16
|
-
} else if (res.statusCode
|
|
17
|
-
|
|
27
|
+
downloadFollowingRedirect(res.headers.location, resolve, reject);
|
|
28
|
+
} else if (res.statusCode >= 400) {
|
|
29
|
+
reject(new Error(`Unable to download '${url}' : ${res.statusCode}-'${res.statusMessage}'`));
|
|
18
30
|
} else {
|
|
19
|
-
|
|
31
|
+
const chunks = [];
|
|
32
|
+
res
|
|
33
|
+
.on('data', chunk => chunks.push(chunk))
|
|
34
|
+
.on('end', () => resolve(Buffer.concat(chunks)))
|
|
35
|
+
.on('error', reject);
|
|
20
36
|
}
|
|
21
37
|
});
|
|
22
38
|
};
|
|
@@ -32,6 +48,7 @@ var downloadAndExtract = function(version) {
|
|
|
32
48
|
reject(error);
|
|
33
49
|
}
|
|
34
50
|
})
|
|
51
|
+
.then(extractZipArchive)
|
|
35
52
|
};
|
|
36
53
|
|
|
37
54
|
install.getVersion(packageJsonPath)
|
package/src/install.js
CHANGED
|
@@ -25,7 +25,12 @@ var getVersion = function(p) {
|
|
|
25
25
|
if(err) {
|
|
26
26
|
reject(err);
|
|
27
27
|
}
|
|
28
|
-
|
|
28
|
+
const pkg = JSON.parse(data);
|
|
29
|
+
if (pkg.version) {
|
|
30
|
+
resolve(pkg.version);
|
|
31
|
+
} else {
|
|
32
|
+
reject(new Error("Unable to find version in package.json."));
|
|
33
|
+
}
|
|
29
34
|
})
|
|
30
35
|
});
|
|
31
36
|
}
|