How to use the bower.config.directory 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 btford / grunt-google-cdn / tasks / cdnify.js View on Github external
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();
    var componentsPath = bowerDirBits.join(path.sep);

    grunt.log
      .writeln('Going through ' + grunt.log.wordlist(files) + ' to update script refs');

    files = files.map(function (filepath) {
      return {
        path: filepath,
        body: grunt.file.read(filepath)
      };
    });

    eachAsync(files, function (file, index, cbInner) {
      var content = file.body;
github btford / grunt-google-cdn / util / bower.js View on Github external
bowerUtil.joinComponent = function joinComponent(component) {
  // Strip the leading path segment from the configured bower components
  // directory. E.g. app/bower_components -> bower_components
  var dirBits = bowerConfig.directory.split(path.sep);
  dirBits.shift();

  // Always join the path with a forward slash, because it's used to replace the
  // path in HTML.
  return path.join(dirBits.join('/'), component).replace(/\\/g, '/');
};