Skip to content

Commit b690805

Browse files
author
Kelly Selden
committed
use getBlueprintRelativeFilePath for ignored files
1 parent a59a07e commit b690805

8 files changed

Lines changed: 68 additions & 19 deletions

File tree

src/get-blueprint-file-path.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ const fs = require('fs-extra');
44
const path = require('path');
55

66
async function getBlueprintFilePath(cwd) {
7+
let relative = await getBlueprintRelativeFilePath(cwd);
8+
9+
return path.join(cwd, relative);
10+
}
11+
12+
async function getBlueprintRelativeFilePath(cwd) {
713
let configDir = 'config';
814

915
try {
@@ -14,7 +20,8 @@ async function getBlueprintFilePath(cwd) {
1420
}
1521
} catch (err) {}
1622

17-
return path.join(cwd, configDir, 'ember-cli-update.json');
23+
return path.join(configDir, 'ember-cli-update.json');
1824
}
1925

2026
module.exports = getBlueprintFilePath;
27+
module.exports.getBlueprintRelativeFilePath = getBlueprintRelativeFilePath;

src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const saveBlueprint = require('./save-blueprint');
1717
const loadDefaultBlueprint = require('./load-default-blueprint');
1818
const loadSafeBlueprint = require('./load-safe-blueprint');
1919
const stageBlueprintFile = require('./stage-blueprint-file');
20-
const getBlueprintFilePath = require('./get-blueprint-file-path');
20+
const { getBlueprintRelativeFilePath } = require('./get-blueprint-file-path');
2121
const isDefaultBlueprint = require('./is-default-blueprint');
2222
const findBlueprint = require('./find-blueprint');
2323
const getBaseBlueprint = require('./get-base-blueprint');
@@ -243,7 +243,7 @@ All blueprints are up-to-date!`;
243243
codemodsUrl,
244244
codemodsJson,
245245
createCustomDiff,
246-
ignoredFiles: [await getBlueprintFilePath(cwd)],
246+
ignoredFiles: [await getBlueprintRelativeFilePath(cwd)],
247247
wasRunAsExecutable
248248
})).promise;
249249

src/init.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const loadDefaultBlueprintFromDisk = require('./load-default-blueprint-from-disk
99
const loadSafeBlueprint = require('./load-safe-blueprint');
1010
const loadSafeBlueprintFile = require('./load-safe-blueprint-file');
1111
const stageBlueprintFile = require('./stage-blueprint-file');
12-
const getBlueprintFilePath = require('./get-blueprint-file-path');
12+
const { getBlueprintRelativeFilePath } = require('./get-blueprint-file-path');
1313
const loadBlueprintFile = require('./load-blueprint-file');
1414
const bootstrap = require('./bootstrap');
1515
const findBlueprint = require('./find-blueprint');
@@ -106,7 +106,7 @@ module.exports = async function init({
106106
baseBlueprint,
107107
endBlueprint: blueprint
108108
}),
109-
ignoredFiles: [await getBlueprintFilePath(cwd)],
109+
ignoredFiles: [await getBlueprintRelativeFilePath(cwd)],
110110
wasRunAsExecutable
111111
})).promise;
112112

src/stage-blueprint-file.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
'use strict';
22

3-
const getBlueprintFilePath = require('./get-blueprint-file-path');
3+
const { getBlueprintRelativeFilePath } = require('./get-blueprint-file-path');
44
const run = require('./run');
55

66
async function stageBlueprintFile(cwd) {
7-
let emberCliUpdateJsonPath = await getBlueprintFilePath(cwd);
7+
let emberCliUpdateJsonPath = await getBlueprintRelativeFilePath(cwd);
88

99
await run(`git add ${emberCliUpdateJsonPath}`);
1010
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"ember-addon": {
3+
"configPath": "config2"
4+
}
5+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"ember-addon": {
3+
}
4+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{
2+
}

test/integration/get-blueprint-file-path-test.js

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,62 @@ const { expect } = require('../helpers/chai');
55
const getBlueprintFilePath = require('../../src/get-blueprint-file-path');
66
const path = require('path');
77

8+
const { getBlueprintRelativeFilePath } = getBlueprintFilePath;
9+
810
describe(getBlueprintFilePath, function() {
9-
it('finds a standard config dir', async function() {
10-
let dir = 'test/fixtures/blueprint/app/local-app/local/my-app';
11+
it('doesn\'t have an ember-addon key', async function() {
12+
let dir = 'test/fixtures/package-json/no-ember-addon';
13+
let expected = 'config/ember-cli-update.json';
1114

1215
let filePath = await getBlueprintFilePath(dir);
1316

14-
expect(path.dirname(filePath)).to.have.basename('config');
15-
expect(filePath).to.be.a.path();
17+
expect(filePath).to.endWith(path.join(dir, expected));
1618
});
1719

18-
it('finds a custom config dir', async function() {
19-
let dir = 'test/fixtures/blueprint/app/legacy-app/local/my-app';
20+
it('doesn\'t have a custom config dir', async function() {
21+
let dir = 'test/fixtures/package-json/no-config-path';
22+
let expected = 'config/ember-cli-update.json';
2023

2124
let filePath = await getBlueprintFilePath(dir);
2225

23-
expect(path.dirname(filePath)).to.not.have.basename('config');
24-
expect(filePath).to.be.a.path();
26+
expect(filePath).to.endWith(path.join(dir, expected));
2527
});
2628

27-
it('falls back if no state file', async function() {
28-
let dir = 'test/fixtures/blueprint/addon/legacy-app/local/no-state-file/my-app';
29+
it('uses a custom config dir', async function() {
30+
let dir = 'test/fixtures/package-json/config-path';
31+
let expected = 'config2/ember-cli-update.json';
2932

3033
let filePath = await getBlueprintFilePath(dir);
3134

32-
expect(path.dirname(filePath)).to.have.basename('config');
33-
expect(filePath).to.not.be.a.path();
35+
expect(filePath).to.endWith(path.join(dir, expected));
36+
});
37+
38+
describe(getBlueprintRelativeFilePath, function() {
39+
it('doesn\'t have an ember-addon key', async function() {
40+
let dir = 'test/fixtures/package-json/no-ember-addon';
41+
let expected = 'config/ember-cli-update.json';
42+
43+
let filePath = await getBlueprintRelativeFilePath(dir);
44+
45+
expect(filePath).to.equal(path.normalize(expected));
46+
});
47+
48+
it('doesn\'t have a custom config dir', async function() {
49+
let dir = 'test/fixtures/package-json/no-config-path';
50+
let expected = 'config/ember-cli-update.json';
51+
52+
let filePath = await getBlueprintRelativeFilePath(dir);
53+
54+
expect(filePath).to.equal(path.normalize(expected));
55+
});
56+
57+
it('uses a custom config dir', async function() {
58+
let dir = 'test/fixtures/package-json/config-path';
59+
let expected = 'config2/ember-cli-update.json';
60+
61+
let filePath = await getBlueprintRelativeFilePath(dir);
62+
63+
expect(filePath).to.equal(path.normalize(expected));
64+
});
3465
});
3566
});

0 commit comments

Comments
 (0)