UNPKG

1.28 kBJavaScriptView Raw
1/* eslint-env node */
2'use strict';
3
4const fs = require('fs');
5
6module.exports = {
7 description: '',
8
9 normalizeEntityName: function() {
10 // this prevents an error when the entityName is
11 // not specified (since that doesn't actually matter
12 // to us
13 },
14
15 afterInstall(options) {
16 return this._insertImportIntoAppCss(options);
17 },
18
19 _insertImportIntoAppCss(options) {
20 let baseDir = options.dummy ? 'tests/dummy/app/styles' : 'app/styles';
21 let text;
22 let appStylesFile;
23
24 if (fs.existsSync(`${baseDir}/app.css`)) {
25 appStylesFile = 'app.css';
26 text = "@import 'tailwind.css'";
27
28 } else if (fs.existsSync(`${baseDir}/app.scss`)) {
29 appStylesFile = 'app.scss';
30 text = "@import 'tailwind'";
31 }
32
33 let appStylesPath = `${baseDir}/${appStylesFile}`;
34
35 // The import isn't necessary for addons, as tailwind will automatically
36 // be concatenated into vendor.css
37 if (fs.existsSync(appStylesPath)) {
38 let contents = fs.readFileSync(appStylesPath, 'utf8');
39
40 if (!contents.match(text)) {
41 fs.writeFileSync(appStylesPath, `${text};\n\n${contents}`, 'utf8');
42 }
43 }
44
45 // Couldn't get this to insert the text at the top of file
46 // return this.insertIntoFile('app/styles/app.css', text);
47 }
48};