Skip to content

Commit

Permalink
Merge pull request #22 from rwjblue/dry-run-does-not-launch-editor
Browse files Browse the repository at this point in the history
Ensure `--dry-run` does not launch editor.
  • Loading branch information
rwjblue authored Mar 27, 2020
2 parents 4ee1ab8 + 0ca7a91 commit ae871bd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ module.exports = class LernaChangelogGeneratorPlugin extends Plugin {
}

async _launchEditor(tmpFile) {
// do not launch the editor for dry runs
if (this.global.isDryRun) {
return;
}

let editorCommand;

if (typeof this.options.launchEditor === 'boolean') {
Expand Down
14 changes: 14 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,20 @@ test('uses launchEditor command', async t => {
t.is(fs.readFileSync(output, 'utf-8'), `args: ${plugin.launchedTmpFile}`);
});

test('does not launch the editor for dry-run', async t => {
let infile = tmp.fileSync().name;

let { editor, output } = await buildEditorCommand();

let plugin = buildPlugin({ infile, launchEditor: `${editor} \${file}` });

plugin.global.isDryRun = true;

await runTasks(plugin);

t.is(fs.readFileSync(output, 'utf-8'), ``);
});

test('detects default editor if launchEditor is `true`', async t => {
let infile = tmp.fileSync().name;

Expand Down

0 comments on commit ae871bd

Please sign in to comment.