Skip to content

Commit c7cb072

Browse files
dfreemanchriskrycho
authored andcommitted
Airlift updatePathsForAddon from the blueprints package
(cherry picked from commit 75f589e)
1 parent bd1758f commit c7cb072

File tree

2 files changed

+47
-2
lines changed

2 files changed

+47
-2
lines changed

ts/blueprints/ember-cli-typescript/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ module.exports = {
7878
2
7979
).replace(/\n/g, '\n '),
8080
pathsFor: (dasherizedName) => {
81-
// We need to wait to use this module until `ember-cli-typescript-blueprints` has been installed
82-
let updatePathsForAddon = require('ember-cli-typescript-blueprints/lib/utilities/update-paths-for-addon');
81+
let updatePathsForAddon = require('./update-paths-for-addon');
8382
let appName = isAddon ? 'dummy' : dasherizedName;
8483
let paths = {
8584
[`${appName}/tests/*`]: ['tests/*'],
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/* eslint-disable no-prototype-builtins */
2+
3+
module.exports = function (paths, addonName, appName, options) {
4+
options = options || {};
5+
const addonNameStar = [addonName, '*'].join('/');
6+
const addonPath = [options.isLinked ? 'node_modules' : 'lib', addonName].join('/');
7+
const addonAddonPath = [addonPath, 'addon'].join('/');
8+
const addonAppPath = [addonPath, 'app'].join('/');
9+
const appNameStar = [appName, '*'].join('/');
10+
const addonTestSupportPath = [addonName, 'test-support'].join('/');
11+
const addonTestSupportStarPath = `${addonTestSupportPath}/*`;
12+
let appStarPaths;
13+
paths = paths || {};
14+
appStarPaths = paths[appNameStar] = paths[appNameStar] || [];
15+
16+
if (options.removePaths) {
17+
if (paths.hasOwnProperty(addonName)) {
18+
delete paths[addonName];
19+
}
20+
if (paths.hasOwnProperty(addonNameStar)) {
21+
delete paths[addonNameStar];
22+
}
23+
let addonAppPathIndex = appStarPaths.indexOf([addonAppPath, '*'].join('/'));
24+
if (addonAppPathIndex > -1) {
25+
appStarPaths.splice(addonAppPathIndex, 1);
26+
paths[appNameStar] = appStarPaths;
27+
}
28+
} else {
29+
if (!paths.hasOwnProperty(addonName)) {
30+
paths[addonName] = [addonAddonPath];
31+
}
32+
if (!paths.hasOwnProperty(addonNameStar)) {
33+
paths[addonNameStar] = [[addonAddonPath, '*'].join('/')];
34+
}
35+
if (!paths.hasOwnProperty(addonTestSupportPath)) {
36+
paths[addonTestSupportPath] = [[addonPath, 'addon-test-support'].join('/')];
37+
}
38+
if (!paths.hasOwnProperty(addonTestSupportStarPath)) {
39+
paths[addonTestSupportStarPath] = [[addonPath, 'addon-test-support', '*'].join('/')];
40+
}
41+
if (appStarPaths.indexOf(addonAppPath) === -1) {
42+
appStarPaths.push([addonAppPath, '*'].join('/'));
43+
paths[appNameStar] = appStarPaths;
44+
}
45+
}
46+
};

0 commit comments

Comments
 (0)