Skip to content

Commit

Permalink
fix: use an absolute path to notepad.exe by default, correct docs
Browse files Browse the repository at this point in the history
  • Loading branch information
nlf authored and wraithgar committed Nov 2, 2022
1 parent ac25863 commit 41843ad
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
6 changes: 3 additions & 3 deletions lib/utils/config/definitions.js
Expand Up @@ -60,7 +60,7 @@ const buildOmitList = obj => {

const editor = process.env.EDITOR ||
process.env.VISUAL ||
(isWindows ? 'notepad.exe' : 'vi')
(isWindows ? `${process.env.SYSTEMROOT}\\notepad.exe` : 'vi')

const shell = isWindows ? process.env.ComSpec || 'cmd'
: process.env.SHELL || 'sh'
Expand Down Expand Up @@ -628,8 +628,8 @@ define('dry-run', {
define('editor', {
default: editor,
defaultDescription: `
The EDITOR or VISUAL environment variables, or 'notepad.exe' on Windows,
or 'vim' on Unix systems
The EDITOR or VISUAL environment variables, or '%SYSTEMROOT%\\notepad.exe' on Windows,
or 'vi' on Unix systems
`,
type: String,
description: `
Expand Down
4 changes: 2 additions & 2 deletions tap-snapshots/test/lib/docs.js.test.cjs
Expand Up @@ -874,8 +874,8 @@ Note: This is NOT honored by other network related commands, eg \`dist-tags\`,
#### \`editor\`
* Default: The EDITOR or VISUAL environment variables, or 'notepad.exe' on
Windows, or 'vim' on Unix systems
* Default: The EDITOR or VISUAL environment variables, or
'%SYSTEMROOT%\\notepad.exe' on Windows, or 'vi' on Unix systems
* Type: String
The command to run for \`npm edit\` and \`npm config edit\`.
Expand Down
10 changes: 8 additions & 2 deletions test/lib/utils/config/definitions.js
Expand Up @@ -33,9 +33,15 @@ t.test('editor', t => {
t.end()
})
t.test('has neither EDITOR nor VISUAL, system specific', t => {
mockGlobals(t, { 'process.env': { EDITOR: undefined, VISUAL: undefined } })
mockGlobals(t, {
'process.env': {
EDITOR: undefined,
VISUAL: undefined,
SYSTEMROOT: 'C:\\Windows',
},
})
const defsWin = mockDefs(isWin(true))
t.equal(defsWin.editor.default, 'notepad.exe')
t.equal(defsWin.editor.default, 'C:\\Windows\\notepad.exe')
const defsNix = mockDefs(isWin(false))
t.equal(defsNix.editor.default, 'vi')
t.end()
Expand Down

0 comments on commit 41843ad

Please sign in to comment.