This commit is contained in:
Shane Harris
2020-08-17 13:31:48 +01:00
committed by Your Name
parent 5968074c2a
commit 21b6fca8b9
2 changed files with 19 additions and 15 deletions
Binary file not shown.
+19 -15
View File
@@ -226,27 +226,28 @@ export class AppService {
} }
} }
seedPlatformTools() { seedPlatformTools() {
return new Promise(resolve => { return new Promise(async resolve => {
if (!this.fs.existsSync(this.path.join(this.appData, 'platform-tools'))) { if (!this.fs.existsSync(this.path.join(this.appData, 'platform-tools'))) {
let sourcesPath = this.path.join(__dirname, '..', 'platform-tools'); let sourcesPath = this.path.join(__dirname, '..', 'platform-tools');
if (!this.fs.existsSync(sourcesPath)) { if (!this.fs.existsSync(sourcesPath)) {
sourcesPath = this.path.join(process.cwd(), 'build', 'platform-tools'); sourcesPath = this.path.join(process.cwd(), 'build', 'platform-tools');
} }
console.log(this.path.join(__dirname, '..', 'platform-tools'), process.cwd(), __dirname); // console.log(this.path.join(__dirname, '..', 'platform-tools'), process.cwd(), __dirname);
this.fs.mkdir(this.path.join(this.appData, 'platform-tools'), () => { await this.mkdir(this.path.join(this.appData, 'platform-tools'));
this.fs.readdir(sourcesPath, (err, files) => { try {
files.forEach(file => { let files = this.fs.readdirSync(sourcesPath);
this.fs files.forEach(file => {
.createReadStream(this.path.join(sourcesPath, file)) this.fs
.pipe(this.fs.createWriteStream(this.path.join(this.appData, 'platform-tools', file))); .createReadStream(this.path.join(sourcesPath, file))
}); .pipe(this.fs.createWriteStream(this.path.join(this.appData, 'platform-tools', file)));
if (this.os.platform() === 'darwin' || this.os.platform() === 'linux') {
this.setExecutable(this.path.join(this.appData, 'platform-tools', 'adb')).then(() => resolve());
} else {
return resolve();
}
}); });
}); if (this.os.platform() === 'darwin' || this.os.platform() === 'linux') {
console.log(this.path.join(this.appData, 'platform-tools', 'adb'));
this.setExecutable(this.path.join(this.appData, 'platform-tools', 'adb')).then(() => resolve());
} else {
return resolve();
}
} catch (e) {}
} }
}); });
} }
@@ -264,6 +265,9 @@ export class AppService {
setExecutable(path) { setExecutable(path) {
return new Promise(resolve => { return new Promise(resolve => {
const ls = this.spawn('chmod', ['+x', path]); const ls = this.spawn('chmod', ['+x', path]);
ls.stdout.on('data', res => {
console.log(res);
});
ls.on('close', code => { ls.on('close', code => {
resolve(); resolve();
}); });