Skip to content

Commit 8f5bb9c

Browse files
committed
fix: depend on user's typescript
Previously, a user of ng-packagr could install an incompatible typescript version for ng-packagr. Prevent inadvertent typescript installs by depending on a user's typescript isntallation (peerDependencies). This should be/is non-breaking as any Angular project requires typescript as devDependency. For Angular v4 support, please make sure to use an appropriate TypeScript version - following ng cli recommendation, this should be >= 2.3.4 and <2.4.0.
1 parent a82d7fe commit 8f5bb9c

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,12 @@
4646
"sorcery": "^0.10.0",
4747
"stylus": "^0.54.5",
4848
"ts-node": "^3.0.4",
49-
"typescript": "^2.3.4",
5049
"uglify-js": "^3.0.7",
5150
"vinyl-fs": "^2.4.4"
5251
},
52+
"peerDependencies": {
53+
"typescript": "^2.3.4"
54+
},
5355
"devDependencies": {
5456
"@angular/cdk": "^2.0.0-beta.11",
5557
"@angular/common": "^4.4.5",
@@ -78,6 +80,7 @@
7880
"rxjs": "^5.4.0",
7981
"sinon": "^4.0.0",
8082
"standard-version": "^4.0.0",
83+
"typescript": "^2.3.4",
8184
"zone.js": "^0.8.10"
8285
},
8386
"private": true,

src/lib/util/json.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
const glob = require('glob')
1+
import * as glob from 'glob';
22
import { readJson, writeJson } from 'fs-extra';
33
import { promisify } from './promisify';
44
import { debug } from './log';
5+
56
/**
67
* Modifies a set of JSON files by invoking `modifyFn`
78
*
@@ -33,8 +34,8 @@ export async function modifyJsonFiles(globPattern: string, modifyFn: (jsonObj: a
3334
export async function tryReadJson(filePath: string): Promise<any> {
3435
try {
3536
return await readJson(filePath);
36-
} catch {
37+
} catch (e) {
3738
// this means the file was empty or not json, which is fine
38-
return {};
39+
return Promise.resolve({});
3940
}
4041
}

0 commit comments

Comments
 (0)