-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #893 from ubports/refactor-0.3.0-beta
Refactor 0.3.0-beta and 0.3.1-beta
- Loading branch information
Showing
27 changed files
with
2,262 additions
and
3,437 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,10 +12,10 @@ Author: Marius Gripsgard <[email protected]> | |
|
||
const builder = require("electron-builder") | ||
const cli = require("commander"); | ||
const utils = require("./src/utils"); | ||
const unzip = require("unzipper"); | ||
const path = require("path"); | ||
const fs = require("fs-extra"); | ||
const download = require('download'); | ||
const events = require("events"); | ||
class event extends events {} | ||
const Platform = builder.Platform | ||
|
@@ -142,8 +142,12 @@ switch (cli.package) { | |
case "": | ||
break; | ||
default: | ||
console.log("Building " + cli.package + " is not configured!"); | ||
process.exit(1); | ||
if (!cli.downloadOnly) { | ||
console.log("Building " + cli.package + " is not configured!"); | ||
process.exit(1); | ||
} else { | ||
break; | ||
} | ||
} | ||
|
||
var build = () => { | ||
|
@@ -175,31 +179,16 @@ var build = () => { | |
|
||
// Download platform tools | ||
if (cli.platformTools) { | ||
const downloadEvent = new event(); | ||
utils.downloadFiles(getAndroidPlatformTools(), downloadEvent); | ||
downloadEvent.on("download:done", () => { | ||
download(getAndroidPlatformTools()[0].url,getAndroidPlatformTools()[0].path).then(() => { | ||
console.log('files downloaded!'); | ||
extractPlatformTools(getAndroidPlatformTools(), () => { | ||
console.log("Platform tools downloaded successfully!"); | ||
if (!cli.downloadOnly) build(); | ||
}); | ||
}); | ||
downloadEvent.on("download:error", (r) => { | ||
console.log("Download error " + r); | ||
}).catch(() => { | ||
console.error("Failed to download files!") | ||
process.exit(1); | ||
}); | ||
downloadEvent.on("error", (r) => { | ||
console.log("Error: " + r); | ||
process.exit(1); | ||
}); | ||
downloadEvent.on("download:start", (r) => { | ||
console.log("Starting download of " + r + " files"); | ||
}); | ||
downloadEvent.on("download:next", (i) => { | ||
console.log(`Downloading next file, ${i} left`); | ||
}); | ||
downloadEvent.on("download:progress", (i) => { | ||
process.stdout.write(`Downloading file, ${Math.ceil(i.percent*100)}% complete\r`); | ||
}); | ||
} else { | ||
build(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.