Finished switching to bower.json

This commit is contained in:
Mat Scales
2013-04-05 16:56:20 +01:00
parent 3dfd95b1dd
commit ec6df96a85
12 changed files with 177 additions and 48 deletions

32
lib/util/fallback.js Normal file
View File

@@ -0,0 +1,32 @@
// ==========================================
// BOWER: fallback
// ==========================================
// Copyright 2012 Twitter, Inc
// Licensed under The MIT License
// http://opensource.org/licenses/MIT
// ==========================================
// A function that takes a list of files and returns the first one that exists
// If none exists, return null
var fileExists = require('./file-exists');
var path = require('path');
var fallback = function (baseDir, files, callback) {
if (!Array.isArray(files) || files.length === 0) {
return callback(null);
}
var file = files.shift();
fileExists(path.join(baseDir, file), function (exists) {
if (!exists) {
return fallback(baseDir, files, callback);
} else {
return callback(file);
}
});
};
module.exports = fallback;