lib/util/get-npmignore.js
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())
}
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())
}
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 ( ) ) }
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.
Creates a function which checks whether or not a given file should be ignored .