How to use the ignore function in ignore

To help you get started, we’ve selected a few ignore examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github flow-typed / flow-typed / definitions / npm / ignore_v4.x.x / flow_v0.25.0- / test_ignore.js View on Github external
// @flow
import ignore from 'ignore';

const ign = ignore();
ignore({});
ignore({ ignorecase: false });
// $ExpectError
ignore({ foo: true });

ign.add('.abc/*');
ign.add(['.abc/*', '!.abc/d/']);
ign.add('.abc/*').add('!.abc/d/');

ign.add(ignore());
ign.add([ignore(), ignore()]);
ign.add(ignore()).add(ignore());

// $ExpectError
ign.add(666);
// $ExpectError
github phodal / dilay / src / compile-check.ts View on Github external
*
 */

import * as fs from "fs";
import * as path from "path";
import ignore from 'ignore'

const colors = require('colors/safe');

import FrameworkHelper from "./helper/framework.helper";
import FileUtil from "./helper/file.util";

const parseIgnore = require('parse-gitignore');

let ignoreFiles = parseIgnore(fs.readFileSync(process.cwd() + '/' + '.gitignore'));
const ig = ignore().add(ignoreFiles);

function compile(filename: string, filePath: string, options: { projectType: string; program: any }) {
  const isDir = fs.lstatSync(filePath).isDirectory();
  const isFile = !isDir;

  const lines: string[] = [];

  // Do not show these regardless.
  if (filename) {
    let filteredPath = ig.filter([filename]);
    if (filteredPath.length === 0) {
      return lines;
    }
  }

  if (isFile) {
github shoutem / cli / src / services / platform-archive.js View on Github external
async loadIgnoreList() {
    const ignoreFilePath = path.join(this.path, SHOUTEM_IGNORE_FILE_NAME);
    const shoutemIgnores = readLinesInFile(ignoreFilePath);

    // no need to remove comments, 'ignores' does that for us
    return ignore().add(shoutemIgnores);
  }
}
github mirabeau-nl / frontend-boilerplate / tasks / codestyle.js View on Github external
function makeFilter(ignoreFile) {
  const ignoreList = fs.readFileSync(ignoreFile, 'utf8').split(/\r?\n/)
  const filter = ignore().add(ignoreList)
  return vinyl => !filter.ignores(vinyl.path)
}
github whitecolor / yalc / src / copy.ts View on Github external
knit?: boolean
    files?: boolean
  }
) => {
  const { workingDir } = options

  const copyFromDir = options.workingDir
  const storePackageStoreDir = join(
    getStorePackagesDir(),
    pkg.name,
    pkg.version
  )

  const ignoreFileContent = readIgnoreFile(workingDir)

  const ignoreRule = ignore().add(ignoreFileContent)
  const npmList: string[] = await npmPacklist({ path: workingDir })
  const filesToCopy = npmList.filter(f => !ignoreRule.ignores(f))
  if (options.files) {
    console.log('Files included in published content:')
    filesToCopy.forEach(f => {
      console.log(`- ${f}`)
    })
    console.log(`Total ${filesToCopy.length} files.`)
  }
  const copyFilesToStore = async () => {
    await fs.remove(storePackageStoreDir)
    return Promise.all(
      filesToCopy
        .sort()
        .map(relPath =>
          copyFile(
github steelbrain / pundle / packages / api / src / rules.js View on Github external
export function matchesRules(relativePath: string, rules: Array): boolean {
  const fileName = Path.basename(relativePath)
  const ignoreRules = []

  for (const rule of rules) {
    if (!(rule instanceof RegExp)) {
      ignoreRules.push(rule)
      continue
    }
    if (rule.test(relativePath) || rule.test(fileName)) {
      return true
    }
  }

  if (ignoreRules.length && createIgnore().add(ignoreRules).filter([relativePath, fileName]).length !== 2) {
    return true
  }

  return false
}
github GDJiaMi / jm-cli / src / cmds / create / index.ts View on Github external
function cloneTemplate(templatePath: string, appPath: string) {
  const ig = ignore()
  const defaultIgnore = ['node_modules', 'dist', 'yarn.*', '.git', '.template-ignore', '.cache-loader']
  ig.add(defaultIgnore)
  const templateIgnorePath = path.join(templatePath, '.template-ignore')

  if (fs.existsSync(templateIgnorePath)) {
    ig.add(fs.readFileSync(templateIgnorePath).toString())
  }

  fs.copySync(templatePath, appPath, {
    overwrite: false,
    errorOnExist: false,
    dereference: true,
    filter: src => {
      const relativePath = path.relative(templatePath, src)
      if (relativePath === '') {
        return true
github MaibornWolff / codecharta / visualization / app / codeCharta / util / codeMapHelper.ts View on Github external
public static isBlacklisted(node: CodeMapNode, blacklist: Array, type: BlacklistType): boolean {
		if (blacklist.length === 0) {
			return false
		}

		const ig = ignore().add(blacklist.filter(b => b.type === type).map(ex => CodeMapHelper.transformPath(ex.path)))
		return ig.ignores(CodeMapHelper.transformPath(node.path))
	}
github nrwl / nx / packages / bazel / src / schematics / init / init.ts View on Github external
return host => {
    if (!host.exists('.gitignore')) {
      return;
    }

    const ig = ignore();
    ig.add(host.read('.gitignore').toString());

    if (!ig.ignores('bazel-out')) {
      const content = `${host
        .read('.gitignore')!
        .toString('utf-8')
        .trimRight()}\nbazel-*\n`;
      host.overwrite('.gitignore', content);
    }
  };
}

ignore

Ignore is a manager and filter for .gitignore rules, the one used by eslint, gitbook and many others.

MIT
Latest version published 3 months ago

Package Health Score

85 / 100
Full package analysis