diff --git a/js/grunt/deployDev.js b/js/grunt/deployDev.js index cbc367dc4..498a9fdeb 100644 --- a/js/grunt/deployDev.js +++ b/js/grunt/deployDev.js @@ -65,20 +65,30 @@ module.exports = function( grunt, buildConfig, callback ) { * scp file to dev server, and call commitAndPushDependenciesJSON if not testing */ var scp = function() { - // create remote version directory if it does not exist - deployUtil.exec( grunt, 'ssh ' + deployConfig.devUsername + '@' + server + ' \'mkdir -p ' + versionPath + '\'', function() { - // add group write permissions to the remote version directory if they don't exist - deployUtil.exec( grunt, 'ssh ' + deployConfig.devUsername + '@' + server + ' \'chmod -R g+w ' + versionPath + '\'', function() { - // copy the local build directory contents to the remote version directory - deployUtil.exec( grunt, 'scp -r ' + ChipperConstants.BUILD_DIR + '/* ' + deployConfig.devUsername + '@' + server + ':' + versionPath, function() { - if ( test ) { - finish(); - } - else { - deployUtil.commitAndPushDependenciesJSON( grunt, finish ); - } + // Check if directory exists + deployUtil.exec( grunt, 'ssh ' + deployConfig.devUsername + '@' + server + ' \'file ' + versionPath + '\'', function( err, stdout, stderr ) { + // If the directory does not exist proceed + if ( stdout.indexOf('No such file or directory') >= 0 ) { + // create remote version directory if it does not exist + deployUtil.exec( grunt, 'ssh ' + deployConfig.devUsername + '@' + server + ' \'mkdir -p ' + versionPath + '\'', function() { + // add group write permissions to the remote version directory if they don't exist + deployUtil.exec( grunt, 'ssh ' + deployConfig.devUsername + '@' + server + ' \'chmod -R g+w ' + versionPath + '\'', function() { + // copy the local build directory contents to the remote version directory + deployUtil.exec( grunt, 'scp -r ' + ChipperConstants.BUILD_DIR + '/* ' + deployConfig.devUsername + '@' + server + ':' + versionPath, function() { + if ( test ) { + finish(); + } + else { + deployUtil.commitAndPushDependenciesJSON( grunt, finish ); + } + } ); + } ); } ); - } ); + } + // If the directory does exist then bail + else { + grunt.fail.fatal('Directory ' + server + ':' + versionPath + ' already exists. If you intend to replace the content then remove the directory manually from ' + server + '.' ); + } } ); }; diff --git a/js/grunt/deployUtil.js b/js/grunt/deployUtil.js index c86148053..ca276548b 100644 --- a/js/grunt/deployUtil.js +++ b/js/grunt/deployUtil.js @@ -29,7 +29,7 @@ var exec = function( grunt, command, callback ) { child_process.exec( command, function( err, stdout, stderr ) { grunt.log.debug( stdout ); grunt.log.debug( stderr ); - callback(); + callback( err, stdout, stderr ); } ); }; @@ -56,7 +56,7 @@ var commitAndPushDependenciesJSON = function( grunt, callback ) { }; var getDependenciesList = function( grunt ) { - + var dependencies; if ( grunt.file.exists( DEPENDENCIES_JSON ) ) { dependencies = grunt.file.readJSON( DEPENDENCIES_JSON ); @@ -86,7 +86,7 @@ var getDependenciesList = function( grunt ) { * @param callback */ var checkForUncommittedChanges = function( grunt, callback ) { - + // get of list of this sim's dependencies var dependenciesList = getDependenciesList( grunt ); @@ -126,7 +126,7 @@ var checkForUncommittedChanges = function( grunt, callback ) { * @param callback */ var checkForUnpushedChanges = function( grunt, callback ) { - + // get of list of this sim's dependencies var dependenciesList = getDependenciesList( grunt ); @@ -179,7 +179,7 @@ var checkForUnpushedChanges = function( grunt, callback ) { * @param callback */ var verifyDependenciesCheckedOut = function( grunt, callback ) { - + grunt.log.debug( 'verifying that correct dependencies are checked out' ); var deployConfig = getDeployConfig( grunt, global.phet.chipper.fs );