UNPKG

accelerator-build-engine

Version:
45 lines (36 loc) 1.3 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs); var _isEmpty = require('lodash/isEmpty'); var _isEmpty2 = _interopRequireDefault(_isEmpty); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } /* eslint no-console: ["error", { allow: ["info", "error"] }] */ class VersionTemplatePlugin { constructor(options = {}) { this.journey = options.journey || ''; this.brand = options.brand || ''; this.filePath = options.filePath || ''; this.noHash = options.noHash || false; } apply(compiler) { compiler.plugin('done', stats => { if (!(0, _isEmpty2['default'])(this.filePath)) { const version = this.noHash ? `${this.journey}${this.brand}` : `${this.journey}${this.brand}@${stats.hash}`; const currentDate = new Date(); const date = `buildDate:${currentDate}`; const content = `${version}\n${date}`; try { _fs2['default'].writeFileSync(this.filePath, content); } catch (ex) { console.error(ex); } } }); } } exports['default'] = VersionTemplatePlugin; module.exports = exports['default']; //# sourceMappingURL=version-template-plugin.js.map