Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | 'use strict'; const fs = require('fs'); const path = require('path'); const { JSDOM } = require('jsdom'); const fuzzyPurgeRequireEntry = require('./utils/fuzzy-purge-require-entry'); module.exports = class BaseManifest { constructor(app, { name, selector }) { this.app = app; this.name = name; this.selector = selector; } get indexPath() { let configPath = this.app.project.configPath(); return path.join(configPath, '..', '..', 'app', 'index.html'); } get element() { let content = fs.readFileSync(this.indexPath, 'utf8'); let dom = new JSDOM(content); return dom.window.document.querySelector(this.selector); } get isRequired() { return this.element !== null; } get configurationPath() { return path.join(this.app.project.root, 'config', 'manifest.js'); } get configuration() { try { let { env, project } = this.app; let config = project.config(env); return project.require('./config/manifest.js')(env, config); } catch (e) { return {}; } } configureFingerprint() { if (!this.isRequired || this.app.options.fingerprint === false) { return; } this.app.options.fingerprint = this.app.options.fingerprint || {}; let defaultOptions = require('broccoli-asset-rev/lib/default-options'); let replaceExtensions = this.app.options.fingerprint.replaceExtensions || defaultOptions.replaceExtensions; let extension = path.extname(this.name).substring(1); this.app.options.fingerprint.replaceExtensions = replaceExtensions.concat([ extension, ]); } build({ directory }) { if (!this.isRequired) { return; } fuzzyPurgeRequireEntry(this.configurationPath); let outputPath = path.join(directory, this.name); let content = this.generate(); fs.writeFileSync(outputPath, content); } generate() { throw new Error('not implemented'); } }; |