@@ -6,6 +6,8 @@ const execa = require('execa');
66
77const BIN_PATH = require . resolve ( '../bin/rwjblue-release-it-setup' ) ;
88const ROOT = process . cwd ( ) ;
9+ const EDITOR = 'EDITOR' in process . env ? process . env . EDITOR : null ;
10+ const PATH = process . env . PATH ;
911
1012function exec ( args ) {
1113 return execa ( process . execPath , [ '--unhandled-rejections=strict' , BIN_PATH , ...args ] ) ;
@@ -18,10 +20,22 @@ describe('main binary', function () {
1820 project = new Project ( 'some-thing-cool' , '0.1.0' ) ;
1921 project . writeSync ( ) ;
2022 process . chdir ( path . join ( project . root , project . name ) ) ;
23+
24+ // ensure an EDITOR is present
25+ process . env . EDITOR = '/bin/whatever' ;
2126 } ) ;
2227
2328 afterEach ( function ( ) {
2429 process . chdir ( ROOT ) ;
30+
31+ // reset process.env.EDITOR to initial state
32+ if ( EDITOR === null ) {
33+ delete process . env . EDITOR ;
34+ } else {
35+ process . env . EDITOR = EDITOR ;
36+ }
37+
38+ process . env . PATH = PATH ;
2539 } ) ;
2640
2741 it ( 'adds CHANGELOG.md file' , async function ( ) {
@@ -178,6 +192,20 @@ describe('main binary', function () {
178192 ` ) ;
179193 } ) ;
180194
195+ it ( 'does not add launchEditor if no $EDITOR is found' , async function ( ) {
196+ delete process . env . EDITOR ;
197+
198+ // have to reset $PATH in order to ensure `launchEditor` is false on Ubuntu systems
199+ // since they always have a `editor` command
200+ process . env . PATH = '' ;
201+
202+ await exec ( [ '--no-install' , '--no-label-updates' ] ) ;
203+
204+ let pkg = JSON . parse ( fs . readFileSync ( 'package.json' , { encoding : 'utf8' } ) ) ;
205+
206+ expect ( pkg [ 'release-it' ] . plugins [ 'release-it-lerna-changelog' ] . launchEditor ) . toBeFalsy ( ) ;
207+ } ) ;
208+
181209 it ( 'adds release-it configuration for monorepos to package.json' , async function ( ) {
182210 project . pkg . workspaces = [ 'packages/*' ] ;
183211 project . writeSync ( ) ;
0 commit comments