Created
November 5, 2017 20:19
-
-
Save arutnik/fd2ddb2d80978b44c3fb8d86e84d75c3 to your computer and use it in GitHub Desktop.
SFA Part 6: Gulp serves
This file contains hidden or 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
| const gulp = require('gulp'); | |
| const run = require('gulp-run'); | |
| const watch = require('gulp-watch'); | |
| const batch = require('gulp-batch'); | |
| gulp.task('deploytosf', () => { | |
| console.log('Running SF deploy script!') | |
| return run('ant localDevDeploy -f salesforce/build.xml -lib salesforce/lib').exec('', function(e) { | |
| if (!(e && e.status)) { | |
| console.log('Page deployed!'); | |
| } | |
| }); | |
| }); | |
| gulp.task('prepareForDeploy', () => { | |
| console.log('Change detected, preparing to deploy!') | |
| return run('python salesforce/visualforce_transform.py --assets sftestassets --controller sftestcontroller --pagename sftestpage --builddir src-dev-deploy').exec('', function(e) { | |
| if (e && e.status) { | |
| console.log("Pre-prep script failed. NOT DEPLOYING"); | |
| if (exitOnFailure) { | |
| process.exit(1); | |
| } | |
| } else { | |
| gulp.start('deploytosf'); | |
| } | |
| }) | |
| }) | |
| gulp.task('watch', () => { | |
| watch(['dist', 'dist/**/index.html'] , batch( { timeout: 2000 }, function(events, cb) { | |
| gulp.start('prepareForDeploy'); | |
| cb(); | |
| })); | |
| }); | |
| gulp.task('localWatch', () => { | |
| setTimeout(() => { | |
| gulp.start('watch'); | |
| }, 5000); | |
| }) | |
| gulp.task('default', ['localWatch']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment