Skip to content

Commit

Permalink
Linted
Browse files Browse the repository at this point in the history
  • Loading branch information
gseguin committed Apr 10, 2014
1 parent 79768c6 commit 12f7df7
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 68 deletions.
11 changes: 5 additions & 6 deletions lib/css.js
Expand Up @@ -21,8 +21,8 @@ function buildBundles( baseName, workspaceDir, relBaseUrl, compiledDir, amdModul
// get the dependency map for all modules
dependencies.buildMap( workspaceDir, relBaseUrl, compiledDir, amdModules ).then(
function( modules ) {
var absBaseUrl = path.normalize( path.join( workspaceDir, relBaseUrl ) );
var cssFiles = {
var absBaseUrl = path.normalize( path.join( workspaceDir, relBaseUrl ) ),
cssFiles = {
default: []
},
contents = {
Expand All @@ -32,8 +32,7 @@ function buildBundles( baseName, workspaceDir, relBaseUrl, compiledDir, amdModul

async.waterfall([
function( next ) {
var name,
processed = {},
var processed = {},
addCssDependencies = function( m ) {
processed[ m ] = true;
if ( !processed[ m ] && modules[ m ] && modules[ m ].deps ) {
Expand All @@ -44,7 +43,7 @@ function buildBundles( baseName, workspaceDir, relBaseUrl, compiledDir, amdModul
// logger.log( "Adding: " + modules[ m ].css );
cssFiles.default = _.union( cssFiles.default, modules[ m ].css.split( "," ) );
} else {
for ( name in modules[ m ].css ) {
for ( var name in modules[ m ].css ) {
if ( modules[ m ].css.hasOwnProperty( name ) ) {
cssFiles[ name ] = cssFiles[ name ] || [];
// logger.log( "Adding css." + name + ": " + modules[ m ].css[ name ]);
Expand Down Expand Up @@ -140,7 +139,7 @@ function buildBundles( baseName, workspaceDir, relBaseUrl, compiledDir, amdModul
optimizeCss: "standard",
logLevel: 4 // SILENT
},
function( response ) {
function() {
async.waterfall([
function( step ) {
fs.readFile( optimizedOut, "utf-8", step );
Expand Down
23 changes: 11 additions & 12 deletions lib/dependencies.js
Expand Up @@ -11,7 +11,7 @@ var async = require( "async" ),
redefineRequireJSLogging = require( "./requirejs-utils" ).redefineRequireJSLogging;

var log,
bid = 0,
// bid = 0,
dependenciesPromises = {};

function getFiles( dir, pattern, mapFn, callback ) {
Expand All @@ -23,11 +23,11 @@ function getFiles( dir, pattern, mapFn, callback ) {
next( null, matches.map( mapFn ) );
}
], callback);
};
}

function buildMap( workspaceDir, baseUrl, compiledDir, include ) {
var id = bid++;
// logger.log( "buildMap["+id+"]()" );
// var id = bid++;
// logger.log( "buildMap["+id+"]()" );
var promise = new Promise(),
shasum = crypto.createHash( 'sha1' ),
filename = "";
Expand Down Expand Up @@ -63,7 +63,7 @@ function buildMap( workspaceDir, baseUrl, compiledDir, include ) {
filename += path.join( compiledDir, "deps-" + digest + ".json" );

fs.exists( filename, function( exists ) {
next( null, digest, exists )
next( null, digest, exists );
});
},
function( digest, exists, next ) {
Expand All @@ -83,7 +83,7 @@ function buildMap( workspaceDir, baseUrl, compiledDir, include ) {
function( cb ) {
// logger.log( "buildMap["+id+"](): step 3.1" );
fs.mkdir( compiledDir, function( err ) {
if ( err && err.code != "EEXIST" ) {
if ( err && err.code !== "EEXIST" ) {
cb( err );
} else {
cb();
Expand All @@ -97,7 +97,7 @@ function buildMap( workspaceDir, baseUrl, compiledDir, include ) {
requirejs.tools.useLib( function( r ) {
r([ 'parse' ], function( parse ) {
cb( null, parse );
})
});
});
},
function( parse, cb ) {
Expand Down Expand Up @@ -134,9 +134,8 @@ function buildMap( workspaceDir, baseUrl, compiledDir, include ) {
// logger.log( "buildMap["+id+"](): step 3.4" );
// Walk through the dep map and remove baseUrl and js extension
var module,
modules = [],
baseUrlRE = new RegExp( "^" + regexp.escapeString( baseUrl + "/" ) ),
jsExtRE = new RegExp( regexp.escapeString( ".js" ) + "$" );
modules = [];

for ( module in deps ) {
modules.push( module );
}
Expand All @@ -151,7 +150,7 @@ function buildMap( workspaceDir, baseUrl, compiledDir, include ) {
function( data, next ) {
// logger.log( "buildMap["+id+"](): step 3.4.2" );
var lines = data.split( "\n" ),
matches = lines.filter( function( line, index ) {
matches = lines.filter( function( line ) {
return /^.*\/\/>>\s*[^:]+:.*$/.test( line );
});
if ( matches && matches.length ) {
Expand Down Expand Up @@ -182,7 +181,7 @@ function buildMap( workspaceDir, baseUrl, compiledDir, include ) {
cb( null, deps );
}
}
)
);
},
function( deps, cb ) {
// logger.log( "buildMap["+id+"](): step 3.5" );
Expand Down
6 changes: 2 additions & 4 deletions lib/git.js
Expand Up @@ -20,8 +20,6 @@
SOFTWARE.
*/



var ChildProcess = require( 'child_process' ),
path = require( 'path' ),
tools = require( './tools' ),
Expand All @@ -32,7 +30,7 @@ var gitCommands, gitDir, workTree;
var gitENOENT = /fatal: (Path '([^']+)' does not exist in '([0-9a-f]{40})'|ambiguous argument '([^']+)': unknown revision or path not in the working tree.)/;

// Set up the git configs for the subprocess
var Git = module.exports = function ( repo, workspace ) {
module.exports.init = function ( repo, workspace ) {
// Check the directory exists first.
try {
fs.statSync( repo );
Expand Down Expand Up @@ -87,4 +85,4 @@ function gitExec( commands, encoding, callback ) {
child.stdin.end();
}

Git.exec = gitExec;
module.exports.exec = gitExec;
64 changes: 32 additions & 32 deletions lib/project.js
Expand Up @@ -14,28 +14,39 @@ var repoBaseDir,
module.exports.repoDir = function setRepoDir( dir ) {
repoBaseDir = path.normalize ( dir );
return module.exports;
}
};

module.exports.stagingDir = function setWorkBaseDir( dir ) {
workBaseDir = path.normalize ( dir );
return module.exports;
}
};

function fetch( repoDir, callback ) {
Git( repoDir );
Git.init( repoDir );
Git.exec( [ "fetch", "origin", "+refs/heads/*:refs/heads/*" ], callback );
}

function remoteUpdate( repoDir, callback ) {
Git( repoDir );
Git.init( repoDir );
Git.exec( [ "remote", "update" ], callback );
}

function getLastCommitHash( repoDir, callback ) {
Git( repoDir );
Git.init( repoDir );
Git.exec( [ "log", "-1", "--pretty=format:%H" ], callback );
}

function getWorkspaceDirSync( project ) {
var workspaceDir;
if ( project.getOwner() ) {
workspaceDir = path.join( project.getWorkspaceBaseDirSync(), project.getRef(), project.getRepo() );
} else {
path.join(project.getRepo(), project.getRef() );
}

return workspaceDir;
}

function cleanup( project, callback ) {
var compiled = project.getCompiledDirSync();

Expand All @@ -58,7 +69,7 @@ function _checkout( project, callback ) {
project.getRepoDir( next );
},
function( dir, next ) {
Git( dir, workDir );
Git.init( dir, workDir );
Git.exec( [ "checkout", "-f", project.getRef() ], next );
}
], callback );
Expand All @@ -81,7 +92,7 @@ function checkout( project, force, callback ){
},
function( next ) {
mkdirp( workDir, function( err ) {
if ( err && err.code != "EEXIST" ) {
if ( err && err.code !== "EEXIST" ) {
next( err );
} else {
next( null );
Expand Down Expand Up @@ -109,7 +120,7 @@ function checkoutIfEmpty( project, callback ){
fs.readdir( workDir, next );
},
function( files, next ) {
if ( files.length == 0 ) {
if ( files.length === 0 ) {
_checkout( project, function() { next(); } );
} else {
next();
Expand Down Expand Up @@ -157,17 +168,6 @@ function getRepoDir( project, callback ) {
getFirstExistingDir( [ repoDir, repoDir + ".git" ], callback );
}

function getWorkspaceDirSync( project ) {
var workspaceDir;
if ( project.getOwner() ) {
workspaceDir = path.join( project.getWorkspaceBaseDirSync(), project.getRef(), project.getRepo() )
} else {
path.join(project.getRepo(), project.getRef() )
}

return workspaceDir;
}

function getCompiledDirSync( project ) {
return path.join( getWorkspaceDirSync( project ), "__compiled" );
}
Expand All @@ -180,64 +180,64 @@ var Project = module.exports.Project = function ( owner, repo, ref ) {

Project.prototype.getOwner = function() {
return this.owner;
}
};

Project.prototype.getRepo = function() {
return this.repo;
}
};

Project.prototype.getRef = function() {
return this.ref;
}
};

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 );
}
};

Project.prototype.getRepoDir = function( callback ) {
return getRepoDir( this, callback );
}
};

Project.prototype.getCompiledDirSync = function() {
return getCompiledDirSync( this );
}
};

Project.prototype.getWorkspaceBaseDirSync = function() {
return getWorkspaceBaseDirSync( this );
}
};

Project.prototype.getWorkspaceDirSync = function() {
return getWorkspaceDirSync( this );
}
};

Project.prototype.fetch = function( callback ) {
async.waterfall([
_.bind( this.getRepoDir, this ),
fetch
], callback );
}
};

Project.prototype.remoteUpdate = function( callback ) {
async.waterfall([
_.bind( this.getRepoDir, this ),
remoteUpdate
], callback );

}
};

Project.prototype.getLastCommitHash = function( callback ) {
async.waterfall([
_.bind( this.getRepoDir, this ),
getLastCommitHash
], callback );
}
};

module.exports.fetch = fetch;
2 changes: 1 addition & 1 deletion lib/regexp.js
Expand Up @@ -13,7 +13,7 @@ regexp.escapeString = function(/*String*/str, /*String?*/except){
// a String with special characters to be left unescaped

return str.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, function(ch){
if(except && except.indexOf(ch) != -1){
if(except && except.indexOf(ch) !== -1){
return ch;
}
return "\\" + ch;
Expand Down

0 comments on commit 12f7df7

Please sign in to comment.