-
Notifications
You must be signed in to change notification settings - Fork 377
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
1 parent
ecd1c4e
commit b4212c7
Showing
7 changed files
with
149 additions
and
3 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -14,3 +14,4 @@ | |
bower.json | ||
ember-cli-build.js | ||
testem.js | ||
node-tests/ |
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
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,9 +1,41 @@ | ||
/* eslint-env node */ | ||
'use strict'; | ||
|
||
const path = require('path'); | ||
const fs = require('fs'); | ||
|
||
module.exports = { | ||
normalizeEntityName: function() { | ||
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 type; | ||
let importStatement = '\n@import "ember-power-select";\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}`); | ||
return this.insertIntoFile(file, importStatement, {}); | ||
} else { | ||
fs.writeFileSync(file, importStatement); | ||
this.ui.writeLine(`Created ${file}`); | ||
} | ||
} | ||
} | ||
}; |
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
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,103 @@ | ||
/* eslint-env node, mocha */ | ||
'use strict'; | ||
|
||
const blueprintHelpers = require('ember-cli-blueprint-test-helpers/helpers'); | ||
const setupTestHooks = blueprintHelpers.setupTestHooks; | ||
const emberNew = blueprintHelpers.emberNew; | ||
const emberGenerate = blueprintHelpers.emberGenerate; | ||
const modifyPackages = blueprintHelpers.modifyPackages; | ||
|
||
const chai = require('ember-cli-blueprint-test-helpers/chai'); | ||
const file = chai.file; | ||
const expect = chai.expect; | ||
|
||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
function createStyleFixture(name) { | ||
let stylePath = path.join('app', 'styles'); | ||
if (!fs.existsSync(stylePath)) { | ||
fs.mkdirSync(stylePath); | ||
} | ||
fs.writeFileSync(path.join(stylePath, name), 'body { color: red; }'); | ||
} | ||
|
||
describe('Acceptance: ember generate ember-power-select', function() { | ||
setupTestHooks(this); | ||
|
||
it('skips blueprint when no preprocessor present', function() { | ||
let args = ['ember-power-select']; | ||
|
||
// pass any additional command line options in the arguments array | ||
return emberNew() | ||
.then(() => emberGenerate(args, (file) => { | ||
expect(file('app/styles/app.scss')).to.not.exist; | ||
expect(file('app/styles/app.less')).to.not.exist; | ||
})); | ||
}); | ||
|
||
it('creates app.scss if not existing', function() { | ||
let args = ['ember-power-select']; | ||
|
||
// pass any additional command line options in the arguments array | ||
return emberNew() | ||
.then(() => modifyPackages([ | ||
{ name: 'ember-cli-sass' } | ||
])) | ||
.then(() => emberGenerate(args)) | ||
.then(() => { | ||
expect(file('app/styles/app.scss')) | ||
.to.contain('@import "ember-power-select";'); | ||
expect(file('app/styles/app.less')).to.not.exist; | ||
}); | ||
}); | ||
|
||
it('adds @import to existing app.scss', function() { | ||
let args = ['ember-power-select']; | ||
|
||
// pass any additional command line options in the arguments array | ||
return emberNew() | ||
.then(() => modifyPackages([ | ||
{ name: 'ember-cli-sass' } | ||
])) | ||
.then(() => createStyleFixture('app.scss')) | ||
.then(() => emberGenerate(args, (file) => { | ||
expect(file('app/styles/app.scss')).to.contain('@import "ember-power-select";'); | ||
expect(file('app/styles/app.less')).to.not.exist; | ||
})); | ||
}); | ||
|
||
it('creates app.less if not existing', function() { | ||
let args = ['ember-power-select']; | ||
|
||
// pass any additional command line options in the arguments array | ||
return emberNew() | ||
.then(() => modifyPackages([ | ||
{ name: 'ember-cli-less' } | ||
])) | ||
.then(() => emberGenerate(args)) | ||
.then(() => { | ||
expect(file('app/styles/app.less')) | ||
.to.contain('@import "ember-power-select";'); | ||
expect(file('app/styles/app.scss')).to.not.exist; | ||
}); | ||
}); | ||
|
||
it('adds @import to existing app.less', function() { | ||
let args = ['ember-power-select']; | ||
|
||
// pass any additional command line options in the arguments array | ||
return emberNew() | ||
.then(() => modifyPackages([ | ||
{ name: 'ember-cli-less' } | ||
])) | ||
.then(() => createStyleFixture('app.less')) | ||
.then(() => emberGenerate(args)) | ||
.then(() => { | ||
expect(file('app/styles/app.less')) | ||
.to.contain('body { color: red; }') | ||
.to.contain('@import "ember-power-select";'); | ||
expect(file('app/styles/app.scss')).to.not.exist; | ||
}); | ||
}); | ||
}); |
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