1 |
|
2 | 'use strict';
|
3 |
|
4 | const fs = require('fs');
|
5 |
|
6 | module.exports = {
|
7 | description: '',
|
8 |
|
9 | normalizeEntityName: function() {
|
10 |
|
11 |
|
12 |
|
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 |
|
36 |
|
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 |
|
46 |
|
47 | }
|
48 | };
|