Created
August 7, 2017 14:59
-
-
Save jpmonette/714712823c21c256635104f4da828dc8 to your computer and use it in GitHub Desktop.
Watching for changes in SFDX project
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
const chokidar = require('chokidar'); | |
const shell = require('shelljs') | |
chokidar | |
.watch('./force-app') | |
.on('change', onChange) | |
// On File Change | |
function onChange (path) { | |
console.log('Updating ' + path + '...') | |
shell.exec('sfdx force:source:push', () => { | |
if (path.indexOf('Test.cls') !== -1) onUpsertTest(path) | |
}) | |
} | |
// On Test Change | |
function onUpsertTest(path) { | |
let fileName = path.split('/')[4].split('.')[0] | |
console.log('Running tests for ' + fileName + '...') | |
shell.exec('sfdx force:apex:test:run --resultformat human --classnames ' + fileName) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment