X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=POLICY-SDK-APP%2Fsrc%2Fmain%2Fwebapp%2Fapp%2FpolicyApp%2FCSS%2Fbootstrap%2Fgrunt%2Fbs-commonjs-generator.js;fp=POLICY-SDK-APP%2Fsrc%2Fmain%2Fwebapp%2Fapp%2FpolicyApp%2FCSS%2Fbootstrap%2Fgrunt%2Fbs-commonjs-generator.js;h=b0642cd8f131f919e68b92fd6fc0da0c2324a054;hb=e0addf5b588a1244f9679becd90999dfcb4c3a94;hp=0000000000000000000000000000000000000000;hpb=39fb0f30472777e4b60d6a7ac8aa4eb9773961ff;p=policy%2Fengine.git diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/CSS/bootstrap/grunt/bs-commonjs-generator.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/CSS/bootstrap/grunt/bs-commonjs-generator.js new file mode 100644 index 000000000..b0642cd8f --- /dev/null +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/CSS/bootstrap/grunt/bs-commonjs-generator.js @@ -0,0 +1,23 @@ +'use strict'; +var fs = require('fs'); +var path = require('path'); + +var COMMONJS_BANNER = '// This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment.\n'; + +module.exports = function generateCommonJSModule(grunt, srcFiles, destFilepath) { + var destDir = path.dirname(destFilepath); + + function srcPathToDestRequire(srcFilepath) { + var requirePath = path.relative(destDir, srcFilepath).replace(/\\/g, '/'); + return 'require(\'' + requirePath + '\')'; + } + + var moduleOutputJs = COMMONJS_BANNER + srcFiles.map(srcPathToDestRequire).join('\n'); + try { + fs.writeFileSync(destFilepath, moduleOutputJs); + } + catch (err) { + grunt.fail.warn(err); + } + grunt.log.writeln('File ' + destFilepath.cyan + ' created.'); +};