Skip to content

Commit 2b5d8fd

Browse files
committedFeb 6, 2024
test: add parse file path test case
1 parent 8ec45e9 commit 2b5d8fd

File tree

5 files changed

+17
-9
lines changed

5 files changed

+17
-9
lines changed
 

‎bin/lc.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ const getCase = (args,opts)=>{
3838
}
3939

4040
const rules = {
41-
'today':(args,opts)=>{
42-
},
41+
'today':(args,opts)=>{},
4342
'random':(args,opts)=>{},
4443
'identity':(args,opts)=>{},
4544
}

‎common/scripts/check.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import {temExe} from "#common/utils/temExe.js";
55
import {readStore} from "#common/utils/store.js";
66
import path from "path";
7+
import {parseFilePath} from "#common/utils/parseFilePath.js";
78
const args = process.argv.slice(2);
89
let name;
910
switch (args[0]) {
@@ -33,7 +34,7 @@ switch (args[0]) {
3334
}
3435
break;
3536
}
36-
const filePath = path.normalize(`./src/${name}/index.js`)
37-
temExe('node "{0}"',filePath)
37+
const filePath = parseFilePath(`./src/${name}/index.js`);
38+
temExe('node {0}',filePath)
3839
.then(res => console.log(`执行结果:\n${res}`))
3940
.catch(e => console.log("执行报错: ", e));

‎common/scripts/test.js

-5
This file was deleted.

‎common/utils/parseFilePath.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import path from "path";
2+
export function parseFilePath(oldPath){
3+
return `\"${path.normalize(oldPath)}\"`;
4+
}

‎test/parseFilePath.spec.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import {describe, expect, it} from "vitest";
2+
import {parseFilePath} from "#common/utils/parseFilePath.js";
3+
4+
const path = "src/LRC 257.pp";
5+
describe("parseFilePath",()=>{
6+
it('是否正确的转化了地址', () => {
7+
expect(parseFilePath(path)).equal(`\"src/LRC 257.pp\"`,"正确解析地址")
8+
})
9+
})

0 commit comments

Comments
 (0)