UNPKG

@sap/generator-cap-project

Version:

Creates a new SAP Cloud Application Programming Model project.

30 lines (29 loc) 909 B
import path from 'path'; import { globbySync } from 'globby'; import multimatch from 'multimatch'; import { setDeletedFileState } from '../state.js'; import { globify } from '../util.js'; function deleteFile(path, store) { const file = store.get(path); setDeletedFileState(file); file.contents = null; store.add(file); } export default function deleteAction(paths, options) { if (!Array.isArray(paths)) { paths = [paths]; } paths = paths.map((filePath) => path.resolve(filePath)); paths = globify(paths); options = options || {}; const globOptions = options.globOptions || {}; const files = globbySync(paths, globOptions); files.forEach((file) => { deleteFile(file, this.store); }); this.store.each((file) => { if (multimatch([file.path], paths).length !== 0) { deleteFile(file.path, this.store); } }); }