Skip to content
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

Downgrade to yn v3 to avoid v4's node 10 requirement #942

Merged
merged 3 commits into from Jan 13, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -83,6 +83,6 @@
"diff": "^4.0.1",
"make-error": "^1.1.1",
"source-map-support": "^0.5.6",
"yn": "^4.0.0"
"yn": "3.1.1"
}
}
11 changes: 10 additions & 1 deletion src/index.ts
@@ -1,6 +1,6 @@
import { relative, basename, extname, resolve, dirname, join } from 'path'
import sourceMapSupport = require('source-map-support')
import * as yn from 'yn'
import * as ynModule from 'yn'
import { BaseError } from 'make-error'
import * as util from 'util'
import * as _ts from 'typescript'
Expand All @@ -26,6 +26,15 @@ declare global {
*/
export const INSPECT_CUSTOM = util.inspect.custom || 'inspect'

/**
* Wrapper around yn module that returns `undefined` instead of `null`.
* This is implemented by yn v4, but we're staying on v3 to avoid v4's node 10 requirement.
*/
function yn (value: string | undefined) {
const parsed = ynModule(value)
return parsed === null ? undefined : parsed
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also just use nullish coalescing within the DEFAULTS object nowadays.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah good point. Even using ??, it's a bit more DRY to keep it within this helper function, and it matches the API of yn v4. Do you still want to get rid of the helper function and move it all to the DEFAULTS object literal?

}

/**
* Debugging `ts-node`.
*/
Expand Down