added platform tools download to build as well as generating compiled code
This commit is contained in:
+5
-2
@@ -9,5 +9,8 @@ v8.setFlagsFromString('--no-lazy');
|
||||
if (!fs.existsSync(__dirname + '/app.jsc') || process.env.NODE_ENV === 'dev') {
|
||||
bytenode.compileFile(__dirname + '/app.js', __dirname + '/app.jsc');
|
||||
}
|
||||
|
||||
require('./app.jsc');
|
||||
if (process.argv.indexOf('gen-code') > -1) {
|
||||
require('electron').app.quit();
|
||||
} else {
|
||||
require('./app.jsc');
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
const https = require('https');
|
||||
const http = require('http');
|
||||
const _fs = require('fs');
|
||||
const { basename } = require('path');
|
||||
const Url = require('url');
|
||||
|
||||
@@ -10,7 +11,7 @@ module.exports = function(url, path, progress) {
|
||||
if (!path) {
|
||||
path = basename(uri.path);
|
||||
}
|
||||
const file = fs.createWriteStream(path);
|
||||
const file = _fs.createWriteStream(path);
|
||||
|
||||
function get(url, callback) {
|
||||
let request = (uri.protocol === 'https:' ? https : http).get(url, function(response) {
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const __fs = require('fs');
|
||||
const extract = require('extract-zip');
|
||||
const download = require('./download');
|
||||
const url = 'https://dl.google.com/android/repository/platform-tools-latest-';
|
||||
let downloadUrl;
|
||||
switch (os.platform()) {
|
||||
case 'win32':
|
||||
downloadUrl = url + 'windows.zip';
|
||||
break;
|
||||
case 'darwin':
|
||||
downloadUrl = url + 'darwin.zip';
|
||||
break;
|
||||
case 'linux':
|
||||
downloadUrl = url + 'linux.zip';
|
||||
break;
|
||||
}
|
||||
console.log('Platform: ' + os.platform());
|
||||
let outputPath = path.join(__dirname, '..', 'build', 'platform-tools');
|
||||
if (!__fs.existsSync(outputPath)) {
|
||||
__fs.mkdir(outputPath, { recursive: true }, err => {
|
||||
if (err) console.log(err);
|
||||
});
|
||||
console.log('Downloading platform tools...');
|
||||
download(downloadUrl, path.join(__dirname, 'platform-tools.zip'), stats => {
|
||||
// console.log(stats);
|
||||
})
|
||||
.then(() => {
|
||||
console.log('Downloaded platform tools.');
|
||||
console.log('Extracting platform tools...');
|
||||
extract(
|
||||
path.join(__dirname, 'platform-tools.zip'),
|
||||
{
|
||||
dir: __dirname,
|
||||
onEntry: entry => {
|
||||
let stats = entry.fileName;
|
||||
// console.log(stats);
|
||||
},
|
||||
},
|
||||
err => {
|
||||
if (err) console.log(err);
|
||||
console.log('Extracted platform tools.');
|
||||
__fs.readdir(path.join(__dirname, 'platform-tools'), (err, files) => {
|
||||
files.forEach(file => {
|
||||
let curPath = path.join(__dirname, 'platform-tools', file);
|
||||
if (!__fs.lstatSync(curPath).isDirectory()) {
|
||||
__fs.rename(curPath, path.join(outputPath, file), function(err) {
|
||||
if (err) console.log(err);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
})
|
||||
.catch(e => {
|
||||
console.log(e);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user