Skip to content
Browse files

Bower task: Quote keys in the RequireJS config if they contain non a-…

…z chars

Fixes #311
  • Loading branch information...
1 parent 56c93bc commit 93f2613f4e1d1608d3b3e6b55469571ec58b5e01 @sindresorhus sindresorhus committed
Showing with 5 additions and 3 deletions.
  1. +5 −3 cli/tasks/bower.js
View
8 cli/tasks/bower.js
@@ -99,12 +99,14 @@ module.exports = function(grunt) {
// check config file exists
if(grunt.file.exists(requireConfigPath)){
// if so..
- // iterate over Bower deps, generating the path string fo config
+ // iterate over Bower deps, generating the path string fo config
Object.keys(deps).forEach(function(dep){
- scripts+= " " + dep + ": '../../" + deps[dep].replace('.js','') + "',\n";
+ // Quote key if it contains non a-z chars
+ var key = /[^\w]/.test( dep ) ? '\'' + dep + '\'' : dep;
+ scripts+= " " + key + ": '../../" + deps[dep].replace('.js','') + "',\n";
});
- // read in the existing data-main config
+ // read in the existing data-main config
var cf = fs.readFileSync(requireConfigPath, 'utf8');
// replace the existing paths with your new paths
var html = cf.replace(' paths: {', 'paths: {\n' + scripts);

0 comments on commit 93f2613

Please sign in to comment.
Something went wrong with that request. Please try again.