Skip to content

Commit 32284d7

Browse files
committed
fix: windows handling of ngcc in postinstall
1 parent 425d081 commit 32284d7

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

packages/nx/src/schematics/application/application.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ function addAppFiles(options: Schema, appName: string, extra: string = ''): Rule
143143
appname,
144144
directoryAppPath: `${directory}${options.name}`,
145145
pathOffset: directory ? '../../../' : '../../',
146+
pathOffsetWindows: directory ? '..\\..\\..\\' : '..\\..\\',
146147
libFolderName: PluginHelpers.getLibFoldername('nativescript'),
147148
angularVersion,
148149
nsAngularVersion,

packages/nx/src/schematics/application/files_angular/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
"license": "SEE LICENSE IN <your-license-filename>",
55
"version": "0.0.0",
66
"scripts": {
7-
"postinstall": "node ./tools/postinstall.js && npm run ngcc",
8-
"ngcc": "<%= pathOffset %>node_modules/.bin/ngcc --tsconfig tsconfig.app.json --properties es2015 module main --first-only"
7+
"postinstall": "node ./tools/postinstall.js"
98
},
109
"dependencies": {
1110
"@nativescript/core": "*"

packages/nx/src/schematics/application/files_angular/tools/postinstall.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
const fs = require('fs-extra');
44
const path = require('path');
5+
const childProcess = require('child_process');
56

67
// Copy potential hooks from root dependencies to app
78
const hooksSrc = '<%= pathOffset %>hooks';
@@ -12,3 +13,12 @@ try {
1213
} catch (err) {
1314
// ignore
1415
}
16+
17+
// Helpful to trigger ngcc after an install to ensure all has processed properly
18+
const child = childProcess.spawn(/^win/.test(process.platform) ? '<%= pathOffsetWindows %>node_modules\\.bin\\ngcc' : '<%= pathOffset %>node_modules/.bin/ngcc', ['--tsconfig', 'tsconfig.app.json', '--properties', 'es2015', 'module', 'main', '--first-only'], {
19+
cwd: process.cwd(),
20+
stdio: 'inherit',
21+
});
22+
child.on('close', (code) => {
23+
24+
});

0 commit comments

Comments
 (0)