Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Checkout if workspace exists but is empty (removes one manual setup s…

…tep)
  • Loading branch information...
commit d66321f11ce78a5fe8c8a0b78966050103381215 1 parent cb7fa62
@gseguin authored
Showing with 48 additions and 6 deletions.
  1. +44 −5 lib/project.js
  2. +1 −1  package.json
  3. +3 −0  server.js
View
49 lib/project.js
@@ -38,6 +38,21 @@ function cleanup( project, callback ) {
], callback );
}
+function _checkout( project, callback ) {
+ // Workspace
+ var workDir = getWorkspaceDirSync( project );
+
+ return async.waterfall([
+ function( next ) {
+ project.getRepoDir( next );
+ },
+ function( dir, next ) {
+ Git( dir, workDir );
+ Git.exec( [ "checkout", "-f", project.getRef() ], next );
+ }
+ ], callback );
+}
+
function checkout( project, force, callback ){
if ( typeof force === "function" ) {
callback = force;
@@ -63,11 +78,7 @@ function checkout( project, force, callback ){
});
},
function( next ) {
- project.getRepoDir( next );
- },
- function( dir, next ) {
- Git( dir, workDir );
- Git.exec( [ "checkout", "-f", project.getRef() ], next );
+ _checkout( project, next );
}
], callback );
} else {
@@ -76,6 +87,30 @@ function checkout( project, force, callback ){
});
}
+function checkoutIfEmpty( project, callback ){
+ // Workspace
+ var workDir = getWorkspaceDirSync( project );
+
+ fs.exists( workDir, function( exists ) {
+ if ( exists ) {
+ async.waterfall([
+ function( next ) {
+ fs.readdir( workDir, next );
+ },
+ function( files, next ) {
+ if ( files.length == 0 ) {
+ _checkout( project, function() { next(); } );
+ } else {
+ next();
+ }
+ }
+ ], callback );
+ } else {
+ callback( "Workspace for " + project.getRepo() + "/" + project.getRef() + " has not been created" );
+ }
+ });
+}
+
function getFirstExistingDir( candidates, callback ) {
var dir = candidates.shift();
fs.exists( dir , function( exists ) {
@@ -148,6 +183,10 @@ Project.prototype.checkout = function( force, callback ) {
return checkout( this, force, callback );
}
+Project.prototype.checkoutIfEmpty = function( callback ) {
+ return checkoutIfEmpty( this, callback );
+}
+
Project.prototype.cleanup = function( callback ) {
return cleanup( this, callback );
}
View
2  package.json
@@ -1,7 +1,7 @@
{
"name":"amd-builder",
"description":"A service that builds bundles from AMD projects resources",
- "version":"0.3.2",
+ "version":"0.3.3",
"keywords":[
"jquery mobile",
"amd",
View
3  server.js
@@ -240,6 +240,9 @@ function buildDependencyMap( project, baseUrl, include ) {
};
async.waterfall([
+ function( next ) {
+ project.checkoutIfEmpty( next );
+ },
function( next ) {
// logger.log( "buildDependencyMap["+id+"](): step 1" );
// If no name is provided, scan the baseUrl for js files and return the dep map for all JS objects in baseUrl
Please sign in to comment.
Something went wrong with that request. Please try again.