Skip to content

Commit

Permalink
feat: remove ts-node (#794)
Browse files Browse the repository at this point in the history
* feat: drop ts-node dependency

* test: use --json for config unset
  • Loading branch information
mdonnalley authored Sep 25, 2023
1 parent e1632db commit a4cb2cb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
"strip-ansi": "^6.0.1",
"supports-color": "^8.1.1",
"supports-hyperlinks": "^2.2.0",
"ts-node": "^10.9.1",
"tslib": "^2.5.0",
"widest-line": "^3.1.0",
"wordwrap": "^1.0.0",
"wrap-ansi": "^7.0.0"
Expand Down Expand Up @@ -72,6 +70,8 @@
"shx": "^0.3.4",
"sinon": "^11.1.2",
"tsd": "^0.29.0",
"ts-node": "^10.9.1",
"tslib": "^2.5.0",
"typescript": "^5"
},
"engines": {
Expand Down
16 changes: 14 additions & 2 deletions src/config/ts-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ function loadTSConfig(root: string): TSConfig | undefined {
} catch {
try {
typescript = require(join(root, 'node_modules', 'typescript'))
} catch {}
} catch {
debug(`Could not find typescript dependency. Skipping ts-node registration for ${root}.`)
memoizedWarn('Could not find typescript. Please ensure that typescript is a devDependency. Falling back to compiled source.')
return
}
}

if (existsSync(tsconfigPath) && typescript) {
Expand All @@ -49,7 +53,15 @@ function registerTSNode(root: string): TSConfig | undefined {
debug('registering ts-node at', root)
const tsNodePath = require.resolve('ts-node', {paths: [root, __dirname]})
debug('ts-node path:', tsNodePath)
const tsNode: typeof TSNode = require(tsNodePath)
let tsNode: typeof TSNode

try {
tsNode = require(tsNodePath)
} catch {
debug(`Could not find ts-node at ${tsNodePath}. Skipping ts-node registration for ${root}.`)
memoizedWarn(`Could not find ts-node at ${tsNodePath}. Please ensure that ts-node is a devDependency. Falling back to compiled source.`)
return
}

const typeRoots = [
join(root, 'node_modules', '@types'),
Expand Down
2 changes: 1 addition & 1 deletion test/integration/sf.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ describe('Salesforce CLI (sf)', () => {

expect(results.failures).to.be.empty

const unset = await executor.executeCommand('config unset disable-telemetry org-api-version --global')
const unset = await executor.executeCommand('config unset disable-telemetry org-api-version --global --json')
const unsetParsed = parseJson(unset.stdout!)
expect(unsetParsed.status).to.equal(0)
})
Expand Down

0 comments on commit a4cb2cb

Please sign in to comment.