Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
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, '/');
};