1 | 'use strict';
|
2 |
|
3 | function getConfigPath(project) {
|
4 | let configDir = 'config';
|
5 |
|
6 | if (project.pkg['ember-addon'] && project.pkg['ember-addon']['configPath']) {
|
7 | configDir = project.pkg['ember-addon']['configPath'];
|
8 | }
|
9 |
|
10 | return `./${configDir}/optional-features.json`;
|
11 | }
|
12 |
|
13 | function join(strings /*, ...args */) {
|
14 | let parts = [];
|
15 |
|
16 | for (let i = 0; i < strings.length - 1; i++) {
|
17 | parts.push(strings[i], arguments[i + 1]);
|
18 | }
|
19 |
|
20 | parts.push(strings[strings.length - 1]);
|
21 |
|
22 | return parts.join('');
|
23 | }
|
24 |
|
25 | function strip(/* strings, ...args */) {
|
26 | let string = join.apply(undefined, arguments);
|
27 | let lines = string.split('\n');
|
28 |
|
29 | if (lines[0] === '') {
|
30 | lines.shift();
|
31 | }
|
32 |
|
33 | if (lines.length === 0) {
|
34 | return '';
|
35 | }
|
36 |
|
37 | let last = lines[lines.length - 1];
|
38 |
|
39 | if (last.trim() === '') {
|
40 | lines[lines.length - 1] = last.trim();
|
41 | }
|
42 |
|
43 | let indent = lines[0].match(/^ */)[0];
|
44 |
|
45 | return lines.map((line) => line.replace(indent, '')).join('\n');
|
46 | }
|
47 |
|
48 | module.exports = {
|
49 | getConfigPath,
|
50 | join,
|
51 | strip,
|
52 | };
|