Skip to content

Commit

Permalink
make sure that you a prompted to add node: current to targets
Browse files Browse the repository at this point in the history
  • Loading branch information
mansona committed Sep 18, 2020
1 parent 75f436c commit 1071cd0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
29 changes: 24 additions & 5 deletions packages/ember-cli-fastboot/blueprints/ember-cli-fastboot/index.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,35 @@
/* eslint-env node */
const recast = require('recast');
const { readFileSync, writeFileSync } = require('fs');
const { join, dirname } = require('path')
const tmp = require('tmp');
const mkdirp = require('mkdirp');

module.exports = {
description: '',
normalizeEntityName() {
// no-op
},

afterInstall() {
let targetsFile = './config/targets.js'
filesPath() {
return this._filesPath;
},

_targetsFile(project) {
let configPath = 'config';

if(this.project.isEmberCLIAddon()) {
targetsFile = './tests/dummy/config/targets.js';
if (project.pkg['ember-addon'] && project.pkg['ember-addon']['configPath']) {
configPath = project.pkg['ember-addon']['configPath'];
}

return join(configPath, 'targets.js');
},

install(options) {
this._filesPath = tmp.dirSync().name;

const targetsFile = this._targetsFile(options.project);

const targetsAst = recast.parse(readFileSync(targetsFile));

recast.visit(targetsAst, {
Expand All @@ -39,6 +54,10 @@ module.exports = {
}
});

writeFileSync(targetsFile, recast.print(targetsAst, { tabWidth: 2, quote: 'single' }).code);
let newFile = join(this._filesPath, targetsFile);
mkdirp.sync(dirname(newFile));
writeFileSync(newFile, recast.print(targetsAst, { tabWidth: 2, quote: 'single' }).code);

return this._super.install.apply(this, arguments);
}
};
4 changes: 3 additions & 1 deletion packages/ember-cli-fastboot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@
"fs-extra": "^7.0.0",
"json-stable-stringify": "^1.0.1",
"md5-hex": "^2.0.0",
"mkdirp": "^1.0.4",
"recast": "^0.19.1",
"silent-error": "^1.1.0"
"silent-error": "^1.1.0",
"tmp": "^0.2.1"
},
"devDependencies": {
"body-parser": "^1.18.3",
Expand Down

0 comments on commit 1071cd0

Please sign in to comment.