Merge branch 'master' of github.com:twitter/bower

This commit is contained in:
André Cruz
2013-01-31 20:02:47 +00:00
14 changed files with 164 additions and 8 deletions

View File

@@ -21,6 +21,7 @@ var async = require('async');
var https = require('https');
var http = require('http');
var path = require('path');
var glob = require('glob');
var url = require('url');
var tmp = require('tmp');
var fs = require('fs');
@@ -237,10 +238,51 @@ Package.prototype.cleanUpLocal = function () {
fs.writeFile(path.join(this.localPath, this.localConfig.json), jsonStr);
if (this.gitUrl || this.gitPath) fs.writeFile(path.join(this.gitPath, this.localConfig.json), jsonStr);
rimraf(path.join(this.localPath, '.git'), this.emit.bind(this, 'install'));
this.removeLocalPaths();
}.bind(this)).readLocalConfig();
};
// finish clean up local by removing .git/ and any ignored files
Package.prototype.removeLocalPaths = function () {
var removePatterns = ['.git'];
if (this.json.ignore) {
removePatterns.push.apply(removePatterns, this.json.ignore);
}
var removePaths = [];
// 3: done
var pathsRemoved = function (err) {
if (err) return this.emit('error', err);
this.emit('install');
}.bind(this);
// 2: trigger after paths have been globbed
var rimrafPaths = function (err) {
if (err) return this.emit('error', err);
async.forEach(removePaths, function (removePath, next) {
// rimraf all the paths
rimraf(removePath, function (err) {
if (err) return this.emit('error', err);
next();
}.bind(this));
// finished callback
}.bind(this), pathsRemoved);
}.bind(this);
// 1: get paths
var globOpts = { dot: true };
async.forEach(removePatterns, function (removePattern, next) {
// glob path for file path pattern matching
var globPattern = path.join(this.localPath, removePattern);
glob(globPattern, globOpts, function (err, globPaths) {
if (err) return this.emit('error', err);
removePaths = removePaths.concat(globPaths);
next();
}.bind(this));
}.bind(this), rimrafPaths);
};
Package.prototype.generateAssetJSON = function () {
return {
name: this.name,