Skip to content

Commit

Permalink
fix: fix hexojs#4334
Browse files Browse the repository at this point in the history
  • Loading branch information
D-Sketon committed Nov 26, 2022
1 parent 58a8f8c commit 2ec8682
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/plugins/console/new.js
Expand Up @@ -33,6 +33,11 @@ function newConsole(args) {
path: args.p || args.path
};

// fix #4334
if (data.path) {
data.path = String(data.path);
}

const keys = Object.keys(args);

for (let i = 0, len = keys.length; i < len; i++) {
Expand Down
22 changes: 22 additions & 0 deletions test/scripts/console/new.js
Expand Up @@ -136,6 +136,28 @@ describe('new', () => {
await unlink(path);
});

// fix #4334
it('path with numbers', async () => {
const date = moment(now);
const path = join(hexo.source_dir, '_posts', '404.md');
const body = [
'title: Hello World',
'date: ' + date.format('YYYY-MM-DD HH:mm:ss'),
'tags:',
'---'
].join('\n') + '\n';

await n({
_: ['Hello World'],
slug: 'foo',
path: 404
});
const content = await readFile(path);
content.should.eql(body);

await unlink(path);
});

it('path - p', async () => {
const date = moment(now);
const path = join(hexo.source_dir, '_posts', 'bar.md');
Expand Down

0 comments on commit 2ec8682

Please sign in to comment.