Skip to content

Commit

Permalink
Added checks for dirs in deploy-dev, passed args to deployUtil #561
Browse files Browse the repository at this point in the history
  • Loading branch information
mattpen committed Apr 17, 2017
1 parent 7f245cb commit 383755b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 18 deletions.
36 changes: 23 additions & 13 deletions js/grunt/deployDev.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 + '.' );
}
} );
};

Expand Down
10 changes: 5 additions & 5 deletions js/grunt/deployUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
} );
};

Expand All @@ -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 );
Expand Down Expand Up @@ -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 );

Expand Down Expand Up @@ -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 );

Expand Down Expand Up @@ -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 );
Expand Down

0 comments on commit 383755b

Please sign in to comment.