Skip to content

Instantly share code, notes, and snippets.

@nuald nuald/buildCopy.js
Created Sep 28, 2016

Embed
What would you like to do?
Cordova gulp build hook
#!/bin/bash
echo "Building Web Project.";
cd ../web/;
gulp;
cd ../cordova/;
echo "Deleting files in ./www";
rm -rf ./www/*;
echo "Copying files from ./web/dist to ./www";
cp -r ../web/dist/* ./www/;
module.exports = (ctx) => {
var Q = ctx.requireCordovaModule('q'),
shell = ctx.requireCordovaModule('shelljs');
var gulpDeferral = new Q.defer(),
exitDeferral = new Q.defer();
console.log("Building Web Project.");
shell.cd('../web/');
shell.exec('gulp', (error, stdout, stderr) => {
if (!error) {
gulpDeferral.resolve();
} else {
exitDeferral.reject('gulp failed!');
}
});
gulpDeferral.promise.then(() => {
console.log("Deleting files in ./www");
shell.cd('../cordova/');
shell.rm('-rf', 'www/*');
console.log("Copying files from ../web/dist to ./www");
shell.cp('-Rf', '../web/dist/*', './www/');
exitDeferral.resolve();
});
return exitDeferral.promise;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.