mirror of
https://github.com/zebrajr/react.git
synced 2025-12-07 00:20:28 +01:00
* Change build process to include npm pack and unpacking generated packages to corresponding build directories. * Update function name, change to use os's default temp directory * appending uuid to temp npm packaging directory.
61 lines
1.2 KiB
JavaScript
61 lines
1.2 KiB
JavaScript
'use strict';
|
|
|
|
const ncp = require('ncp').ncp;
|
|
const join = require('path').join;
|
|
const resolve = require('path').resolve;
|
|
const exec = require('child_process').exec;
|
|
const targz = require('targz');
|
|
|
|
function asyncCopyTo(from, to) {
|
|
return new Promise(_resolve => {
|
|
ncp(from, to, error => {
|
|
if (error) {
|
|
console.error(error);
|
|
process.exit(1);
|
|
}
|
|
_resolve();
|
|
});
|
|
});
|
|
}
|
|
|
|
function resolvePath(path) {
|
|
if (path[0] === '~') {
|
|
return join(process.env.HOME, path.slice(1));
|
|
} else {
|
|
return resolve(path);
|
|
}
|
|
}
|
|
|
|
function asyncExecuteCommand(command) {
|
|
return new Promise(_resolve =>
|
|
exec(command, (error, stdout) => {
|
|
if (!error) {
|
|
_resolve(stdout);
|
|
} else {
|
|
console.error(error);
|
|
process.exit(1);
|
|
}
|
|
})
|
|
);
|
|
}
|
|
|
|
function asyncExtractTar(options) {
|
|
return new Promise(_resolve =>
|
|
targz.decompress(options, error => {
|
|
if (!error) {
|
|
_resolve();
|
|
} else {
|
|
console.error(error);
|
|
process.exit(1);
|
|
}
|
|
})
|
|
);
|
|
}
|
|
|
|
module.exports = {
|
|
asyncCopyTo: asyncCopyTo,
|
|
resolvePath: resolvePath,
|
|
asyncExecuteCommand: asyncExecuteCommand,
|
|
asyncExtractTar: asyncExtractTar,
|
|
};
|