angular-write-constants
Advanced tools
Comparing version 1.0.0 to 1.0.1
21
index.js
@@ -5,2 +5,6 @@ 'use strict'; | ||
function macroStyleKey(key) { | ||
return key.replace(/[^A-Z][A-Z]/g, m => m[0] + '_' + m[1]).toUpperCase(); | ||
} | ||
exports.constantList = function(files, moduleName) { | ||
@@ -10,13 +14,18 @@ const j = {}; | ||
files.forEach(file => { | ||
Object.assign(j, JSON.parse(fs.readFileSync(file))); | ||
const origJSON = JSON.parse(fs.readFileSync(file)); | ||
const macroStyleKeysJSON = {}; | ||
Object.keys(origJSON).forEach(k => { | ||
macroStyleKeysJSON[macroStyleKey(k)] = origJSON[k]; | ||
}); | ||
Object.assign(j, macroStyleKeysJSON); | ||
}); | ||
let s = 'angular.module("' + moduleName + '")\n' + | ||
Object.keys(j).map(key => { | ||
const macroStyleKey = key.replace(/[^A-Z][A-Z]/g, m => m[0] + '_' + m[1]).toUpperCase(); | ||
return ' .constant("' + macroStyleKey + '", ' + JSON.stringify(j[key]) + ')'; | ||
}).join('\n') + ';\n'; | ||
Object.keys(j).map(key => ( | ||
' .constant("' + key + '", ' + JSON.stringify(j[key]) + ')' | ||
)).join('\n') + ';\n'; | ||
return s; | ||
}; |
{ | ||
"name": "angular-write-constants", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Create a JS config for angular using constants", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4972
34