Skip to content

Commit 9b7b701

Browse files
alan-agius4dherges
authored andcommitted
fix: copy nested triple slash referenced typings to correct path (#1009)
Prior to this change, the folder structure was not being retained when coping the `d.ts` files to the `dist` path Closes #1007
1 parent 1f79aa2 commit 9b7b701

File tree

5 files changed

+27
-2
lines changed

5 files changed

+27
-2
lines changed

integration/samples/typings/specs/typings.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,15 @@ describe(`sample-typings`, () => {
2929
expect(CHALK_DTS).to.be.ok;
3030
});
3131
});
32+
33+
describe(`src/nested/reference/mocked.d.ts`, () => {
34+
let MOCKED_DTS;
35+
before(() => {
36+
MOCKED_DTS = fs.readFileSync(path.resolve(__dirname, '..', 'dist', 'nested/reference/mocked.d.ts'), 'utf-8');
37+
});
38+
39+
it(`should exist in 'dist' folder`, () => {
40+
expect(MOCKED_DTS).to.be.ok;
41+
});
42+
});
3243
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/// <reference path="./mocked.d.ts" />
2+
3+
export const faz: Mocked = { foo: 'bar' };
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
interface Mocked {
2+
foo: string;
3+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export * from './validator';
2+
export * from './nested/reference/index';

src/lib/ng-v5/entry-point/write-package.transform.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { rimraf } from '../../util/rimraf';
88
import * as log from '../../util/log';
99
import { globFiles } from '../../util/glob';
1010
import { EntryPointNode, isEntryPointInProgress } from '../nodes';
11-
import { copyFiles } from '../../util/copy';
1211

1312
export const writePackageTransform: Transform = transformFromPromise(async graph => {
1413
const entryPoint = graph.find(isEntryPointInProgress()) as EntryPointNode;
@@ -23,7 +22,15 @@ export const writePackageTransform: Transform = transformFromPromise(async graph
2322
ignore: ['**/node_modules/**', `${ngPackage.dest}/**`]
2423
});
2524

26-
await copyFiles(declarationFiles, path.dirname(destinationFiles.declarations));
25+
if (declarationFiles.length) {
26+
await Promise.all(
27+
declarationFiles.map(value => {
28+
const relativePath = path.relative(ngEntryPoint.entryFilePath, value);
29+
const destination = path.resolve(destinationFiles.declarations, relativePath);
30+
return fs.copy(value, destination);
31+
})
32+
);
33+
}
2734

2835
// 6. WRITE PACKAGE.JSON
2936
log.info('Writing package metadata');

0 commit comments

Comments
 (0)