|
1 | 1 | import * as fs from 'fs-extra'; |
| 2 | +import * as path from 'path'; |
2 | 3 | import { hook } from 'capture-console'; |
3 | 4 | import ember from 'ember-cli-blueprint-test-helpers/lib/helpers/ember'; |
4 | 5 | import blueprintHelpers from 'ember-cli-blueprint-test-helpers/helpers'; |
@@ -109,6 +110,13 @@ describe('Acceptance: ts:precompile command', function () { |
109 | 110 | pkg.name = '@foo/my-addon'; // addon `name` is `my-addon` |
110 | 111 | fs.writeJSONSync('package.json', pkg); |
111 | 112 |
|
| 113 | + // CAUTION! HACKY CODE AHEAD! |
| 114 | + // The ember blueprint helper stays in the same node process, so require |
| 115 | + // keeps any previously read files cached. We need to clear out these |
| 116 | + // caches so it picks up the changes properly. |
| 117 | + delete require.cache[path.join(process.cwd(), 'index.js')]; |
| 118 | + delete require.cache[path.join(process.cwd(), 'package.json')]; |
| 119 | + |
112 | 120 | return ember(['ts:precompile']).then(() => { |
113 | 121 | const declaration = file('test-support/test-file.d.ts'); |
114 | 122 | expect(declaration).to.exist; |
@@ -136,6 +144,13 @@ describe('Acceptance: ts:precompile command', function () { |
136 | 144 | pkg.name = '@foo/my-addon'; // addon `moduleName()` is `my-addon` |
137 | 145 | fs.writeJSONSync('package.json', pkg); |
138 | 146 |
|
| 147 | + // CAUTION! HACKY CODE AHEAD! |
| 148 | + // The ember blueprint helper stays in the same node process, so require |
| 149 | + // keeps any previously read files cached. We need to clear out these |
| 150 | + // caches so it picks up the changes properly. |
| 151 | + delete require.cache[path.join(process.cwd(), 'index.js')]; |
| 152 | + delete require.cache[path.join(process.cwd(), 'package.json')]; |
| 153 | + |
139 | 154 | return ember(['ts:precompile']).then(() => { |
140 | 155 | const componentDecl = file('components/my-component.d.ts'); |
141 | 156 | expect(componentDecl).to.exist; |
|
0 commit comments