Skip to content

Commit 9799c3a

Browse files
committed
test: Add the sidebar file already exists test
1 parent 916479a commit 9799c3a

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

Diff for: e2e/commands/generate.test.js

+3
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,7 @@ test('generate _sidebar.md', t => {
2525
run(['generate', 'docs'], {cwd: genPath})
2626
// Check for existence
2727
t.true(fs.existsSync(path.join(docsPath, '_sidebar.md')))
28+
29+
const {stderr} = run(['generate', 'docs'], {cwd: genPath})
30+
t.is(stderr, 'the sidebar file \'_sidebar.md\' already exists.')
2831
})

Diff for: lib/commands/generate.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module.exports = function (path = '', sidebar) {
2121
return true
2222
}
2323

24-
console.error(chalk.red(`${sidebarPath}`) + ' already exists.')
24+
console.error(chalk.red(`the sidebar file '${sidebar}' already exists.`))
2525
return false
2626
}
2727
}

Diff for: lib/commands/init.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module.exports = function (path = '', local, theme) {
2222
const cwdPath = cwd(path || '.')
2323

2424
if (exists(cwdPath)) {
25-
console.log(chalk.red(`${path || '.'}`) + ' already exists.')
25+
console.log(chalk.red(`${path || '.'} already exists.`))
2626

2727
prompt({
2828
type: 'confirm',

0 commit comments

Comments
 (0)