Skip to content

Commit

Permalink
fix: depend on user's typescript
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dherges committed Nov 14, 2017
1 parent a82d7fe commit 8f5bb9c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@
"sorcery": "^0.10.0",
"stylus": "^0.54.5",
"ts-node": "^3.0.4",
"typescript": "^2.3.4",
"uglify-js": "^3.0.7",
"vinyl-fs": "^2.4.4"
},
"peerDependencies": {
"typescript": "^2.3.4"
},
"devDependencies": {
"@angular/cdk": "^2.0.0-beta.11",
"@angular/common": "^4.4.5",
Expand Down Expand Up @@ -78,6 +80,7 @@
"rxjs": "^5.4.0",
"sinon": "^4.0.0",
"standard-version": "^4.0.0",
"typescript": "^2.3.4",
"zone.js": "^0.8.10"
},
"private": true,
Expand Down
7 changes: 4 additions & 3 deletions src/lib/util/json.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const glob = require('glob')
import * as glob from 'glob';
import { readJson, writeJson } from 'fs-extra';
import { promisify } from './promisify';
import { debug } from './log';

/**
* Modifies a set of JSON files by invoking `modifyFn`
*
Expand Down Expand Up @@ -33,8 +34,8 @@ export async function modifyJsonFiles(globPattern: string, modifyFn: (jsonObj: a
export async function tryReadJson(filePath: string): Promise<any> {
try {
return await readJson(filePath);
} catch {
} catch (e) {
// this means the file was empty or not json, which is fine
return {};
return Promise.resolve({});
}
}

0 comments on commit 8f5bb9c

Please sign in to comment.