-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
ember-basic-dropdown/blueprints/ember-basic-dropdown/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* eslint-env node */ | ||
'use strict'; | ||
|
||
const path = require('path'); | ||
const fs = require('fs'); | ||
const EOL = require('os').EOL; | ||
|
||
module.exports = { | ||
normalizeEntityName() { | ||
// this prevents an error when the entityName is | ||
// not specified (since that doesn't actually matter | ||
// to us | ||
}, | ||
|
||
afterInstall() { | ||
let dependencies = this.project.dependencies(); | ||
let skipStyleImport = false; | ||
|
||
if ('ember-power-select' in dependencies) { | ||
skipStyleImport = true; | ||
} | ||
|
||
if (!skipStyleImport) { | ||
let type; | ||
let importStatement = '\n@import "ember-basic-dropdown";\n'; | ||
if ('ember-cli-sass' in dependencies) { | ||
type = 'scss'; | ||
} else if ('ember-cli-less' in dependencies) { | ||
type = 'less'; | ||
} | ||
|
||
if (type) { | ||
let stylePath = path.join('app', 'styles'); | ||
let file = path.join(stylePath, `app.${type}`); | ||
|
||
if (!fs.existsSync(stylePath)) { | ||
fs.mkdirSync(stylePath); | ||
} | ||
if (fs.existsSync(file)) { | ||
this.ui.writeLine(`Added import statement to ${file}`); | ||
this.insertIntoFile(file, importStatement, {}); | ||
} else { | ||
fs.writeFileSync(file, importStatement); | ||
this.ui.writeLine(`Created ${file}`); | ||
} | ||
} else { | ||
let file = path.join('app', `app.js`); | ||
if (!fs.existsSync(file)) { | ||
file = path.join('app', `app.ts`); | ||
} | ||
if (fs.existsSync(file)) { | ||
this.ui.writeLine(`Added import statement to ${file}`); | ||
this.insertIntoFile(file, "import 'ember-basic-dropdown/styles';", { | ||
after: "config/environment';" + EOL, | ||
}); | ||
} | ||
} | ||
} | ||
|
||
let templatePath = path.join('app', 'templates'); | ||
let applicationFile = path.join(templatePath, `application.hbs`); | ||
if (fs.existsSync(applicationFile)) { | ||
this.ui.writeLine(`Added wormhole statement to ${applicationFile}`); | ||
this.insertIntoFile( | ||
applicationFile, | ||
`${EOL}<BasicDropdownWormhole />`, | ||
{}, | ||
); | ||
} | ||
|
||
this.cleanRemove('<BasicDropdownWormhole />'); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters