Created
September 28, 2016 01:21
-
-
Save nuald/3a7df998b2a5e2ea008493c651ea53eb to your computer and use it in GitHub Desktop.
Cordova gulp build hook
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
#!/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/; |
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
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