Files
linux-odyssey/packages/utils/commands.js
T
2023-10-29 17:41:38 +08:00

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)]
}