Skip to content

Commit ca2aa93

Browse files
committed
fix: the command of change disks is only available in Windows
1 parent b14ea54 commit ca2aa93

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

jsconfig.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,13 @@
77
"importHelpers": true,
88
"moduleResolution": "node",
99
"resolveJsonModule": true,
10-
"suppressImplicitAnyIndexErrors": true,
1110
"forceConsistentCasingInFileNames": true,
1211
"experimentalDecorators": true,
1312
"skipLibCheck": true,
1413
"esModuleInterop": true,
1514
"incremental": false,
1615
"allowSyntheticDefaultImports": true,
1716
"sourceMap": true,
18-
"types": ["node"],
1917
"lib": ["esnext", "dom", "dom.iterable"]
2018
},
2119
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.js"],

src/index.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const { platform } = require('os')
12
const { resolve } = require('path')
23
const { execSync } = require('child_process')
34
const getConfig = require('./libs/getConfig')
@@ -50,21 +51,24 @@ function start() {
5051
}
5152

5253
// Create CMDs
53-
const cmds = [
54+
const commands = [
5455
`cd ${resolve(repo)}`,
5556
'git pull',
5657
`git log --pretty=format:"%an|||%ae|||%s|||'%h|||%ad"`,
5758
]
5859

60+
// Windows may have multiple disk partitions
5961
// Change the disk path when repo and program are on different disks
60-
const curDiskSymbol = process.argv0.split(':')[0]
61-
if (!String(repo).startsWith(curDiskSymbol)) {
62-
const diskSymbol = String(repo).split(':')[0]
63-
cmds.unshift(`${diskSymbol}:`)
62+
if (platform() === 'win32') {
63+
const curDiskSymbol = process.argv0.split(':')[0]
64+
if (!String(repo).startsWith(curDiskSymbol)) {
65+
const diskSymbol = String(repo).split(':')[0]
66+
commands.unshift(`${diskSymbol}:`)
67+
}
6468
}
6569

6670
// Gel full command
67-
const cmd = cmds.join(' && ')
71+
const cmd = commands.join(' && ')
6872

6973
// Get commit records from git repo
7074
const res = execSync(cmd)
@@ -75,7 +79,7 @@ function start() {
7579
.filter((log) => reg.include.test(log))
7680
.filter((log) => !reg.exclude.test(log))
7781

78-
// Meger all logs
82+
// Merge all logs
7983
logs.forEach((log) => allLogs.push(`${repoName}|||${log}`))
8084
})
8185

0 commit comments

Comments
 (0)