mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-05 19:20:12 +08:00
17 lines
357 B
JavaScript
17 lines
357 B
JavaScript
const fileTypes = {
|
|
file: '-f',
|
|
folder: '-d',
|
|
link: '-L',
|
|
socket: '-S',
|
|
}
|
|
|
|
function sanitizePath(path) {
|
|
return path.replace(/[^a-zA-Z0-9._/-]/g, '')
|
|
}
|
|
|
|
// eslint-disable-next-line import/prefer-default-export
|
|
export function buildFileCheckCmd(file) {
|
|
const { path, type } = file
|
|
return ['test', fileTypes[type] || '-e', sanitizePath(path)]
|
|
}
|