main-bower-files
Advanced tools
Comparing version 1.0.3 to 2.0.0
@@ -8,59 +8,50 @@ var fs = require('fs'), | ||
files, | ||
bowerrcJson, | ||
defaults = { | ||
paths: { | ||
bowerJson: './bower.json', | ||
bowerrc: './.bowerrc', | ||
bowerDirectory: './bower_components' | ||
} | ||
}; | ||
config, | ||
bowerrc, | ||
bowerJson, | ||
bowerDirectory, | ||
cwd = process.cwd(); | ||
opts = opts || {}; | ||
opts.paths = opts.paths || {}; | ||
if (!opts.paths) { | ||
opts.paths = {}; | ||
if (typeof opts.paths === 'string') { | ||
cwd = path.resolve(cwd, opts.paths); | ||
} else { | ||
bowerrc = opts.paths.bowerrc; | ||
} | ||
if (typeof opts.paths === 'string'){ | ||
opts.paths = { | ||
bowerJson : path.join(opts.paths, defaults.paths.bowerJson), | ||
bowerrc : path.join(opts.paths, defaults.paths.bowerrc), | ||
bowerDirectory : path.join(opts.paths, defaults.paths.bowerDirectory) | ||
}; | ||
} | ||
bowerrc = path.resolve(cwd, bowerrc || '.bowerrc'); | ||
opts.paths.bowerJson = opts.paths.bowerJson || defaults.paths.bowerJson; | ||
opts.paths.bowerrc = opts.paths.bowerrc || defaults.paths.bowerrc; | ||
opts.paths.bowerDirectory = opts.paths.bowerDirectory || defaults.paths.bowerDirectory; | ||
if (fs.existsSync(opts.paths.bowerrc)){ | ||
bowerrcJson = JSON.parse(fs.readFileSync(opts.paths.bowerrc)); | ||
if (bowerrcJson && bowerrcJson.directory) { | ||
opts.paths.bowerDirectory = path.dirname(opts.paths.bowerrc); | ||
opts.paths.bowerDirectory = path.join( | ||
opts.paths.bowerDirectory, | ||
'/', | ||
bowerrcJson.directory | ||
); | ||
if (fs.existsSync(bowerrc) && (config = JSON.parse(fs.readFileSync(bowerrc)))) { | ||
cwd = path.dirname(bowerrc); | ||
if (config.cwd) { | ||
cwd = path.resolve(cwd, config.cwd); | ||
} | ||
if (config.directory) { | ||
bowerDirectory = config.directory; | ||
} | ||
} | ||
if (!opts.paths.bowerJson || !fs.existsSync(opts.paths.bowerJson)){ | ||
throw new Error('bower.json file does not exist at ' + opts.paths.bowerJson); | ||
} | ||
bowerJson = opts.paths.bowerJson ? path.resolve(process.cwd(), opts.paths.bowerJson) | ||
: path.resolve(cwd, bowerJson || 'bower.json'); | ||
if (!opts.paths.bowerDirectory || !fs.existsSync(opts.paths.bowerDirectory)){ | ||
throw new Error('Bower components directory does not exist at ' + | ||
opts.paths.bowerDirectory); | ||
} | ||
bowerDirectory = opts.paths.bowerDirectory ? path.resolve(process.cwd(), opts.paths.bowerDirectory) | ||
: path.resolve(cwd, bowerDirectory || 'bower_components'); | ||
if (!opts.base) { | ||
opts.base = opts.paths.bowerDirectory; | ||
if (!bowerJson || !fs.existsSync(bowerJson)) { | ||
throw new Error('bower.json file does not exist at ' + bowerJson); | ||
} | ||
if (!opts.includeDev) { | ||
opts.includeDev = false; | ||
if (!bowerDirectory || !fs.existsSync(bowerDirectory)) { | ||
throw new Error('Bower components directory does not exist at ' + bowerDirectory); | ||
} | ||
opts.base = opts.base || bowerDirectory; | ||
opts.includeDev = opts.includeDev || false; | ||
opts.paths = { | ||
bowerJson: bowerJson, | ||
bowerDirectory: bowerDirectory | ||
}; | ||
try { | ||
@@ -67,0 +58,0 @@ collection = new PackageCollection(opts); |
{ | ||
"name": "main-bower-files", | ||
"version": "1.0.3", | ||
"version": "2.0.0", | ||
"description": "Get main files from your installed bower packages.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30493
620