How to use the bower.config function in bower

To help you get started, we’ve selected a few bower examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zumwald / oss-attribution-generator / index.js View on Github external
// first - check that this is even a bower project
    var baseDir;
    if (Array.isArray(options.baseDir)) {
        baseDir = options.baseDir[0];
        if (options.baseDir.length > 1) {
            console.warn("Checking multiple directories is not yet supported for Bower projects.\n" +
                "Checking only the first directory: " + baseDir);
        }
    }
    if (!jetpack.exists(path.join(baseDir, 'bower.json'))) {
        console.log('this does not look like a Bower project, skipping Bower checks.');
        return [];
    }

    bower.config.cwd = baseDir;
    var bowerComponentsDir = path.join(bower.config.cwd, bower.config.directory);
    return jetpack.inspectTreeAsync(bowerComponentsDir, { relativePath: true })
        .then((result) => {
            /**
             * for each component, try to calculate the license from the NPM package info
             * if it is a available because license-checker more closely aligns with our
             * objective.
             */
            return bluebird.map(result.children, (component) => {
                var absPath = path.join(bowerComponentsDir, component.relativePath);
                // npm license check didn't work
                // try to get the license and package info from .bower.json first
                // because it has more metadata than the plain bower.json
      
                var package = '';
      
                try {
github endel / lazy-assets / lib / lazy / utils.js View on Github external
var files = (asset.main && asset.main.split(",")) || [],
          fullDir = this.getPath(asset.href)
          dir = path.basename(fullDir),
          jsonPath = fullDir + '/bower.json';

      if (files.length === 0 && fs.existsSync(jsonPath)) {
        var json = JSON.parse(fs.readFileSync(jsonPath).toString());
        if (json.main) {
          if (typeof(json.main)==="string") {
            json.main = [json.main];
          }
          files = files.concat(json.main);
        }
      }

      var directory = bower.config.directory.replace(this.getBasePath(), "");

      // Try another main file from alternative patterns
      if (files.length === 0) {
        var dependency_root = directory + "/" + dir;

        // it 'seems' we need recursivity here. lazy programming
        var found, patterns = [
          dependency_root + '/' + dir,
          dependency_root + '/' + dir + '.min.{js,css}',
          dependency_root + '/' + dir + '.{js,css}',
          dependency_root + '/' + dir + '.min.{js,css}',
          dependency_root + '/jquery.' + dir,
          dependency_root + '/jquery.' + dir + '.{js,css}',
          dependency_root + '/jquery.' + dir + '.min.{js,css}',
          dependency_root + '/{css,dist,build}/' + dir,
          dependency_root + '/{css,dist,build}/' + dir + '.{js,css}',
github btford / grunt-google-cdn / tasks / cdnify.js View on Github external
'use strict';

var path = require('path');
var eachAsync = require('each-async');
var googlecdn = require('google-cdn');
var bowerConfig = require('bower').config;
var chalk = require('chalk');

module.exports = function (grunt) {

  grunt.registerMultiTask('cdnify', 'Replace scripts with refs to the Google CDN', function () {
    // collect files
    var files = grunt.file.expand({ filter: 'isFile' }, this.data.html);
    var compJson = grunt.file.readJSON('bower.json');
    var options = this.options({
      cdn: 'google'
    });

    // Strip the leading path segment off, e.g. `app/bower_components` ->
    // `bower_components`
    var bowerDirBits = bowerConfig.directory.split(path.sep);
    bowerDirBits.shift();
github happyplan / happyplan / grunt_tasks / lib / load-config.js View on Github external
// (happyplan default first, parents, & the local)
  var happyplan = deepmerge(grunt.config.get('pkg'), grunt.file.readJSON(happyplanRoot + '/happyplan.json'))

  happyplan.env = grunt.option('env')
  grunt.verbose.writeln('Environnment is'.grey, happyplan.env)

  happyplan.cwd = process.cwd()
  grunt.verbose.writeln('CWD is'.grey, happyplan.cwd.cyan)

  happyplan._ = happyplanRoot
  grunt.verbose.writeln('happyplan wd is'.grey, happyplan._.cyan)

  happyplan.pkg = grunt.file.readJSON(happyplanRoot + '/package.json')

  // load bower config
  happyplan.bower_components = require('bower').config.directory

  grunt.config.set('happyplan', happyplan)
}
github JonAbrams / synth / lib / commands.js View on Github external
var both = !!(nodeModuleIndex && bowerComponentIndex);

  if (nodeModuleIndex || both) {
    var nodeModules = getModules(args, nodeModuleIndex);

    process.chdir('back');
    npm.load({ save: true }, function (err) {
      npm.commands.uninstall(nodeModules);
    });
  }

  if (bowerComponentIndex || both) {
    var bowerComponents = getModules(args, bowerComponentIndex);

    process.chdir('front');
    bower.config.cwd = process.cwd();
    promises = {};
    bowerComponents.forEach(function(component, index){
      promises[component] = new Promise(function(resolve){
        bower.commands.info(component).on('end', function(info){
          return resolve({
            pkgMeta: info.latest
          });
        });
      });
    });
    bower.commands[command](bowerComponents, { save: true })
    .on('end', function (uninstalled) {
      Promise.props(promises).then(function(infos){
        /* Remove uninstalled components from the asset manifest files */
        bowerSupport.removeFromManifestFiles(infos);
      });
github walmartlabs / lumbar / test / libraries.js View on Github external
beforeEach(function() {
      require('bower').config.directory = 'bower_components';
    });
github cgross / bowinst / lib / cmd / install.js View on Github external
var installComponent = function(name){

        var bowerjson = util.component(name);
        if (!bowerjson){
            console.log('Unable to find component ' + chalk.bold(name) + ' in ' + chalk.bold(bower.config.directory) + '.  Is it installed?');
            return;
        }

        var config = util.config();

        var files = util.arrayify(bowerjson.main);

        config.extensions.forEach(function(ext){

            var matchingFiles = _.filter(files,function(file){
                return minimatch(file,ext.files,{matchBase:true});
            });

            if (matchingFiles.length > 0) {
                ext.module.install(matchingFiles,bowerjson,ext.options);
            }
github BradDenver / Preen / lib / preen.js View on Github external
function preen(options, callback) {
  
  preview = options.preview;
  verbose = options.verbose;
  directory = options.directory;

  if(preview || verbose){
    logger.transports.console.level = 'verbose';
  }

  try {
    bowerJSON = require(process.cwd()+'/'+bower.config.json);
  }
  catch(err) {
    logger.error('Error trying to read '+bower.config.json, err);
    return;
  }

  async.each(Object.keys(bowerJSON.preen), preenPackage, callback);
}
github walmartlabs / generator-release / diff / index.js View on Github external
_.each(this.changed, function(change) {
    var packageDir, notes;

    if (self.isBower) {
      packageDir = change.bowerRoot ? '' : bower.config.directory + '/' + change.name + '/';
    } else {
      packageDir = change.npmRoot ? '' : 'node_modules/' + change.name.replace(/\//g, '/node_modules/') + '/';
    }

    try {
      notes = fs.readFileSync(packageDir + 'RELEASE.md');
    } catch (err) {
      try {
        notes = fs.readFileSync(packageDir + 'release-notes.md');
      } catch (err) {
        try{
          notes = fs.readFileSync(packageDir + 'CHANGELOG.md');
        } catch (err) {
          notes = '';
        }
      }
github cgross / bowinst / lib / util.js View on Github external
components: function(){

        //should use bower API but 'list' seems broken from the api
        return _(fs.readdirSync(bower.config.directory)).filter(function(file){
            return fs.lstatSync(path.join(bower.config.directory,file)).isDirectory();
        });
    },