-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathstandalone.js
46 lines (43 loc) · 1.03 KB
/
standalone.js
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
39
40
41
42
43
44
45
46
'use strict';
const os = require('os');
const fetch = require('node-fetch');
const platform = (() => {
switch (process.platform) {
case 'darwin':
return 'macos';
default:
return process.platform;
}
})();
const arch = (() => {
switch (process.arch) {
case 'x32':
return 'x86';
case 'arm':
return 'armv6';
case 'arm64':
if (process.platform === 'darwin') {
// Handle case of M1 Macs that are using x64 binary via Rosetta
return 'x64';
}
return 'armv6';
default:
return process.arch;
}
})();
module.exports = {
resolveLatestTag: async () => {
const response = await fetch(
'https://api.github.com/repos/serverless/serverless/releases/latest'
);
const data = await response.json();
return data.tag_name;
},
resolveUrl: (tagName) => {
return (
`https://github.com/serverless/serverless/releases/download/${tagName}/` +
`serverless-${platform}-${arch}`
);
},
path: `${os.homedir()}/.serverless/bin/serverless`,
};