-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathinstall.js
41 lines (33 loc) · 1.16 KB
/
install.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
const BinWrapper = require('bin-wrapper');
const spinner = require('simple-spinner');
const config = require('./config');
const {cleanFile} = require('./utils');
/**
* Installs the Theme Kit executable into the bin/ subdirectory.
* Call this on npm postinstall.
* @param {string} logLevel Log level
*/
async function install(logLevel) {
const logger = require('./logger')(logLevel);
const urlAndPath = `${config.baseURL}/v${config.version}`;
logger.silly('Theme Kit installation starting');
spinner.start();
const installer = new BinWrapper()
.src(`${urlAndPath}/darwin-amd64/theme`, 'darwin')
.src(`${urlAndPath}/linux-386/theme`, 'linux')
.src(`${urlAndPath}/linux-amd64/theme`, 'linux', 'x64')
.src(`${urlAndPath}/windows-386/theme.exe`, 'win32')
.src(`${urlAndPath}/windows-amd64/theme.exe`, 'win32', 'x64')
.dest(config.destination)
.use(config.binName);
const pathToExecutable = installer.path();
cleanFile(pathToExecutable);
try {
await installer.run(['version']);
spinner.stop();
logger.info(`Theme Kit path: ${pathToExecutable}`);
} catch (err) {
throw new Error(err);
}
}
module.exports = install;