/** * Creates a function which checks whether or not a given file should be ignored. * * @param {string} basedir - The directory path "package.json" exists. * @param {boolean} filesFieldExists - `true` if `files` field of `package.json` exists. * @returns {function|null} A function which checks whether or not a given file should be ignored. */ function parseNpmignore(basedir, filesFieldExists) { let filePath = path.join(basedir, ".npmignore") if (!exists(filePath)) { if (filesFieldExists) { return null } filePath = path.join(basedir, ".gitignore") if (!exists(filePath)) { return null } } const ig = ignore() ig.add(fs.readFileSync(filePath, "utf8")) return not(ig.createFilter()) }
async listFiles(srcPath){ const ig = ignore() const distignoreFile = path.join(srcPath, '.distignore') if(fs.existsSync(distignoreFile)) { ig.add(fs.readFileSync(distignoreFile).toString()) } const files = await fglob('**', { dot: true, cwd: srcPath, }); return ig.filter(files) }
/** * @param {path} cPath */ function handleIgnode(cPath, ignoreList) { const relativePath = cPath.replace(ROOTPATH, ''); const ig = ignore().add(ignoreList); return ig.ignores(relativePath); }
const ig = ignore().add(restrictedPatterns);
const ig = ignore().add(restrictedPatterns);
async listFiles(sourceDirectory){ const ig = ignore() const gitignoreFile = path.join(sourceDirectory, '.gitignore') if(fs.existsSync(gitignoreFile)) { ig.add(fs.readFileSync(gitignoreFile).toString()) } ig.add(['/node_modules']) //never upload node_modules const files = await fglob('**', { dot: true, cwd: sourceDirectory, }); return ig.filter(files); }
/** * @param {path} cPath */ function handleIgnode(cPath, ignoreList) { var relativePath = cPath.replace(ROOTPATH, ''); var ig = ignore().add(ignoreList); return ig.ignores(relativePath); }