Updating the Values.yaml for several services. Cleaned out proprietary data
[it/otf.git] / otf-frontend / ng-add-pug-loader.js
1 /**
2  * Adds the pug-loader inside Angular CLI's webpack config, if not there yet.
3  * @see https://github.com/danguilherme/ng-cli-pug-loader
4  */
5 const fs = require('fs');
6 const commonCliConfig = 'node_modules/@angular-devkit/build-angular/src/angular-cli-files/models/webpack-configs/common.js';
7 const pugRules = ` { test: /\.(pug|jade)$/, exclude: /\.(include|partial)\.(pug|jade)$/, use: [ { loader: 'apply-loader' }, { loader: 'pug-loader' } ] }, { test: /\.(include|partial)\.(pug|jade)$/, loader: 'pug-loader' },`;
8
9 fs.readFile(commonCliConfig, (err, data) => {
10   if (err) throw err;
11
12   const configText = data.toString();
13   // make sure we don't add the rule if it already exists
14   if (configText.indexOf(pugRules) > -1) { return; }
15
16   // Insert the pug webpack rule
17   const position = configText.indexOf('rules: [') + 8;
18   const output = [configText.slice(0, position), pugRules, configText.slice(position)].join('');
19   const file = fs.openSync(commonCliConfig, 'r+');
20   fs.writeFile(file, output, error => {
21     if (error)
22       console.error("An error occurred while overwriting Angular CLI's Webpack config");
23
24     fs.close(file, () => {});
25   });
26 });