mirror of
https://github.com/Llewellynvdm/nativefier.git
synced 2025-01-05 07:02:10 +00:00
Add progress bar
This commit is contained in:
parent
e1f2e662e9
commit
7ad7c346ef
@ -47,6 +47,7 @@
|
|||||||
"lodash": "^4.0.0",
|
"lodash": "^4.0.0",
|
||||||
"ncp": "^2.0.0",
|
"ncp": "^2.0.0",
|
||||||
"page-icon": "^0.2.0",
|
"page-icon": "^0.2.0",
|
||||||
|
"progress": "^1.1.8",
|
||||||
"request": "^2.67.0",
|
"request": "^2.67.0",
|
||||||
"sanitize-filename": "^1.5.3",
|
"sanitize-filename": "^1.5.3",
|
||||||
"shelljs": "^0.5.3",
|
"shelljs": "^0.5.3",
|
||||||
|
@ -4,7 +4,7 @@ import tmp from 'tmp';
|
|||||||
import ncp from 'ncp';
|
import ncp from 'ncp';
|
||||||
import async from 'async';
|
import async from 'async';
|
||||||
import hasBinary from 'hasbin';
|
import hasBinary from 'hasbin';
|
||||||
|
import ProgressBar from 'progress';
|
||||||
import optionsFactory from './../options/optionsMain';
|
import optionsFactory from './../options/optionsMain';
|
||||||
import iconBuild from './iconBuild';
|
import iconBuild from './iconBuild';
|
||||||
import helpers from './../helpers/helpers';
|
import helpers from './../helpers/helpers';
|
||||||
@ -27,14 +27,28 @@ const isWindows = helpers.isWindows;
|
|||||||
function buildMain(options, callback) {
|
function buildMain(options, callback) {
|
||||||
// pre process app
|
// pre process app
|
||||||
|
|
||||||
var tmpObj = tmp.dirSync({unsafeCleanup: true});
|
const tmpObj = tmp.dirSync({unsafeCleanup: true});
|
||||||
const tmpPath = tmpObj.name;
|
const tmpPath = tmpObj.name;
|
||||||
|
|
||||||
|
const bar = new ProgressBar(' :task [:bar] :percent', {
|
||||||
|
complete: '=',
|
||||||
|
incomplete: ' ',
|
||||||
|
total: 5,
|
||||||
|
width: 50,
|
||||||
|
clear: true
|
||||||
|
});
|
||||||
|
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
callback => {
|
callback => {
|
||||||
|
bar.tick({
|
||||||
|
task: 'infering'
|
||||||
|
});
|
||||||
optionsFactory(options, callback);
|
optionsFactory(options, callback);
|
||||||
},
|
},
|
||||||
(options, callback) => {
|
(options, callback) => {
|
||||||
|
bar.tick({
|
||||||
|
task: 'copying'
|
||||||
|
});
|
||||||
buildApp(options.dir, tmpPath, options, error => {
|
buildApp(options.dir, tmpPath, options, error => {
|
||||||
if (error) {
|
if (error) {
|
||||||
callback(error);
|
callback(error);
|
||||||
@ -46,19 +60,38 @@ function buildMain(options, callback) {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
(options, callback) => {
|
(options, callback) => {
|
||||||
|
bar.tick({
|
||||||
|
task: 'icons'
|
||||||
|
});
|
||||||
iconBuild(options, (error, optionsWithIcon) => {
|
iconBuild(options, (error, optionsWithIcon) => {
|
||||||
callback(null, optionsWithIcon);
|
callback(null, optionsWithIcon);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
(options, callback) => {
|
(options, callback) => {
|
||||||
|
bar.tick({
|
||||||
|
task: 'packaging'
|
||||||
|
});
|
||||||
// maybe skip passing icon parameter to electron packager
|
// maybe skip passing icon parameter to electron packager
|
||||||
const packageOptions = maybeNoIconOption(options);
|
const packageOptions = maybeNoIconOption(options);
|
||||||
|
|
||||||
|
// suppress 'Packaging app for...' from electron-packager
|
||||||
|
// todo check if this is still needed on later version of packager
|
||||||
|
const consoleError = console.error;
|
||||||
|
console.error = () => {};
|
||||||
|
|
||||||
packager(packageOptions, (error, appPathArray) => {
|
packager(packageOptions, (error, appPathArray) => {
|
||||||
|
|
||||||
|
// restore console.error
|
||||||
|
console.error = consoleError;
|
||||||
|
|
||||||
// pass options which still contains the icon to waterfall
|
// pass options which still contains the icon to waterfall
|
||||||
callback(error, options, appPathArray);
|
callback(error, options, appPathArray);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
(options, appPathArray, callback) => {
|
(options, appPathArray, callback) => {
|
||||||
|
bar.tick({
|
||||||
|
task: 'finalizing'
|
||||||
|
});
|
||||||
// somehow appPathArray is a 1 element array
|
// somehow appPathArray is a 1 element array
|
||||||
const appPath = getAppPath(appPathArray);
|
const appPath = getAppPath(appPathArray);
|
||||||
if (!appPath) {
|
if (!appPath) {
|
||||||
|
Loading…
Reference in New Issue
Block a user