#!/usr/bin/env node | ||
'use strict'; | ||
require('../index.js')(); | ||
var bowerJsonPath = 'bower.json'; | ||
// check for one of the arguments | ||
var next; | ||
process.argv.forEach(function (arg) { | ||
if (next) { | ||
bowerJsonPath = arg; | ||
if (bowerJsonPath.search('bower.json') === -1) { | ||
bowerJsonPath + '/bower.json'; | ||
} | ||
next = false; | ||
} | ||
if (arg === '--bowerJSON') { | ||
next = true; | ||
} | ||
}); | ||
require('../index.js')(bowerJsonPath); |
19
index.js
@@ -6,6 +6,6 @@ var fs = require('fs'); | ||
module.exports = function () { | ||
module.exports = function (bowerFilePath) { | ||
var bowerContents; | ||
try { | ||
bowerContents = require(process.cwd() + path.sep + 'bower.json'); | ||
bowerContents = require(process.cwd() + path.sep + bowerFilePath); | ||
} catch (e) { | ||
@@ -25,9 +25,8 @@ console.log('No bower.json meta file detected. I`m outta here'); | ||
try { | ||
bowerMeta = JSON.parse(fs.readFileSync(process.cwd() + path.sep + '.bowerrc', 'utf-8')); | ||
bowerMeta.directory = bowerMeta.directory ? bowerMeta.directory : 'bower_components'; | ||
bowerMeta = JSON.parse(fs.readFileSync(process.cwd() + path.sep + bowerFilePath.replace('bower.json', '') + '.bowerrc', 'utf-8')); | ||
bowerMeta.directory = process.cwd() + path.sep + bowerFilePath.replace('bower.json', '') + (bowerMeta.directory ? bowerMeta.directory : 'bower_components'); | ||
} catch (e) { | ||
bowerMeta = {directory: 'bower_components'}; | ||
bowerMeta = {directory: process.cwd() + path.sep + bowerFilePath.replace('bower.json', '') + 'bower_components'}; | ||
}; | ||
// is there a components folder?, otherwise we can exit because we have nothing to do | ||
@@ -42,3 +41,3 @@ if(!fs.existsSync(bowerMeta.directory)) { | ||
var depPath = basePath + path.sep + dependency; | ||
// nothing to do if the dependency folder does not exist | ||
// nothing to do if the dependency folder does not exist | ||
if (!fs.existsSync(depPath)) { | ||
@@ -48,3 +47,3 @@ console.log('Dependency not found', dependency) | ||
} | ||
var meta; | ||
@@ -61,3 +60,3 @@ try { | ||
} | ||
// check if this is a tagged git repo, then split to get the version | ||
@@ -91,2 +90,2 @@ var _version = metaData.split('#'); | ||
console.log('All done. Thanks for watching!'); | ||
}; | ||
}; |
{ | ||
"name": "bower-pi", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "Validates bower dependency versions pre install", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
5852
9.71%91
22.97%