-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpost-install-mac.js
More file actions
35 lines (34 loc) · 1.17 KB
/
post-install-mac.js
File metadata and controls
35 lines (34 loc) · 1.17 KB
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
#!/usr/bin/env node
const { exec } = require("child_process");
const fspath = require('path');
const fs = require('fs');
let tarUnzipDir;
exec('npm root -g', (error, stdout, stderr) => {
if( error || stderr){
console.log("error determining npm global node_modules location", error || stderr);
}
if(stdout){
stdout= stdout.trim();
tarUnzipDir = fspath.join(stdout,'azure-devops-work-items-mac','dist','mac');
makeDir(stdout);
}
});
const makeDir = (_path) => {
console.log('making directory to tar extract into');
fs.mkdir(tarUnzipDir, {recursive: true}, (err)=> {
if(err) throw err;
console.log('made: ', fspath.join(_path,'azure-devops-work-items-mac','dist','mac'));
unzipFile(_path);
});
}
const unzipFile = (_path) => {
const zipPath = fspath.join(_path, 'azure-devops-work-items-mac','dist','mac.tar.gz');
const destPath = tarUnzipDir;
console.log('extracting archive...');
exec(`tar -xvzf ${zipPath} -C ${destPath}`, (error, stdout, stderr) => {
if( error ){
console.log("error extracting archive", error );
}
console.log('archive extracted');
});
}