New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(init): init package with better main, types #179
Conversation
Codecov Report
@@ Coverage Diff @@
## master #179 +/- ##
=======================================
Coverage 99.13% 99.13%
=======================================
Files 10 10
Lines 460 460
Branches 31 31
=======================================
Hits 456 456
Misses 4 4 Continue to review full report at Codecov.
|
src/init.ts
Outdated
// TODO(ofrobots): add proper error handling. | ||
cp.spawnSync('npm', ['init', '-y']); | ||
packageJson = await readJson('./package.json'); | ||
packageJson = DEFUALT_PACKAGE_JSON; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need the try-catch here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed not. Removed.
@@ -21,7 +21,19 @@ import * as path from 'path'; | |||
import {Options} from './cli'; | |||
import {readFilep as read, readJsonp as readJson, writeFileAtomicp as write} from './util'; | |||
|
|||
const pkg = require('../../package.json') as PackageJson; | |||
const pkg = require('../../package.json'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did the type annotation here disappear?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That wasn't an annotation but rather a cast. The cast was not necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also – we don't use this yet – but going forward we would stronger types for package.json available from new resolveJsonModule in TS 2.9.
Fixes: #144