lib/ignore.js
function ignore(dir, options) {
  var jpmignore = path.join(dir, ".jpmignore");
  var defaultRules = ["*.zip", ".*", "test/", ".jpmignore", "*.xpi"];

  return utils.getManifest({addonDir: options.addonDir})
    .then(function(manifest) {
      return fs.exists(jpmignore);
    })
    .then(function(exists) {
      if (exists) {
        if (options.verbose) {
          console.log(".jpmignore found");
        }
        return fs.stat(jpmignore)
          .then(function(stat) {
            if (stat.isFile()) {
              return fs.readFile(jpmignore)
                .then(function(data) {
                  return data.toString().replace(/[\r\n]/, "\n").split("\n");
                });
            } else {
              console.warn(
                ".jpmignore is not a file, fallback to use " +
                  "default filter rules");
              return defaultRules;
            }
          });
      } else {
        if (options.verbose) {
          console.warn(
            ".jpmignore does not exist, fallback to use default filter rules");
        }
        return defaultRules;
      }
    })
    .then(function(lines) {
      // Add "manifest.json" to always exclude it from the xpi (See
      // https://github.com/mozilla-jetpack/jpm/pull/566 for rationale),
      // but ensure the "webextension/manifest.json", that is used for the
      // webextension embedded in an SDK hybrid add-on, is always included
      // (See https://github.com/mozilla-jetpack/jpm/pull/578 for rationale).
      lines = ["manifest.json", "!webextension/manifest.json"].concat(lines);

      var rules = lines.filter(function(e) {
        // exclude blank lines and comments
        return !/^\s*(#|$)/.test(e);
      });
      // http://git-scm.com/docs/gitignore
      // the last matching pattern decides the outcome
      // reverse rules and break at first matched rule when filtering
      return rules.reverse().map(function(rule) {
        return new Minimatch(rule, {
          matchBase: true,
          dot: true,
          flipNegate: true
        });
      });
    })
    .then(function(rules) {
      return listdir(dir, rules, dir, true);
    });
}
function ignore(dir, options) {
  var jpmignore = path.join(dir, ".jpmignore");
  var defaultRules = ["*.zip", ".*", "test/", ".jpmignore", "*.xpi"];

  return utils.getManifest({addonDir: options.addonDir})
    .then(function(manifest) {
      return fs.exists(jpmignore);
    })
    .then(function(exists) {
      if (exists) {
        if (options.verbose) {
          console.log(".jpmignore found");
        }
        return fs.stat(jpmignore)
          .then(function(stat) {
            if (stat.isFile()) {
              return fs.readFile(jpmignore)
                .then(function(data) {
                  return data.toString().replace(/[\r\n]/, "\n").split("\n");
                });
            } else {
              console.warn(
                ".jpmignore is not a file, fallback to use " +
                  "default filter rules");
              return defaultRules;
            }
          });
      } else {
        if (options.verbose) {
          console.warn(
            ".jpmignore does not exist, fallback to use default filter rules");
        }
        return defaultRules;
      }
    })
    .then(function(lines) {
      // Add "manifest.json" to always exclude it from the xpi (See
      // https://github.com/mozilla-jetpack/jpm/pull/566 for rationale),
      // but ensure the "webextension/manifest.json", that is used for the
      // webextension embedded in an SDK hybrid add-on, is always included
      // (See https://github.com/mozilla-jetpack/jpm/pull/578 for rationale).
      lines = ["manifest.json", "!webextension/manifest.json"].concat(lines);

      var rules = lines.filter(function(e) {
        // exclude blank lines and comments
        return !/^\s*(#|$)/.test(e);
      });
      // http://git-scm.com/docs/gitignore
      // the last matching pattern decides the outcome
      // reverse rules and break at first matched rule when filtering
      return rules.reverse().map(function(rule) {
        return new Minimatch(rule, {
          matchBase: true,
          dot: true,
          flipNegate: true
        });
      });
    })
    .then(function(rules) {
      return listdir(dir, rules, dir, true);
    });
}
function ignore ( dir , options ) { var jpmignore = path . join ( dir , ".jpmignore" ) ; var defaultRules = [ "*.zip" , ".*" , "test/" , ".jpmignore" , "*.xpi" ] ; return utils . getManifest ( { addonDir : options . addonDir } ) . then ( function ( manifest ) { return fs . exists ( jpmignore ) ; } ) . then ( function ( exists ) { if ( exists ) { if ( options . verbose ) { console . log ( ".jpmignore found" ) ; } return fs . stat ( jpmignore ) . then ( function ( stat ) { if ( stat . isFile ( ) ) { return fs . readFile ( jpmignore ) . then ( function ( data ) { return data . toString ( ) . replace ( / [\r\n] / , "\n" ) . split ( "\n" ) ; } ) ; } else { console . warn ( ".jpmignore is not a file, fallback to use " + "default filter rules" ) ; return defaultRules ; } } ) ; } else { if ( options . verbose ) { console . warn ( ".jpmignore does not exist, fallback to use default filter rules" ) ; } return defaultRules ; } } ) . then ( function ( lines ) { // Add "manifest.json" to always exclude it from the xpi (See // https://github.com/mozilla-jetpack/jpm/pull/566 for rationale), // but ensure the "webextension/manifest.json", that is used for the // webextension embedded in an SDK hybrid add-on, is always included // (See https://github.com/mozilla-jetpack/jpm/pull/578 for rationale). lines = [ "manifest.json" , "!webextension/manifest.json" ] . concat ( lines ) ; var rules = lines . filter ( function ( e ) { // exclude blank lines and comments return ! / ^\s*(#|$) / . test ( e ) ; } ) ; // http://git-scm.com/docs/gitignore // the last matching pattern decides the outcome // reverse rules and break at first matched rule when filtering return rules . reverse ( ) . map ( function ( rule ) { return new Minimatch ( rule , { matchBase : true , dot : true , flipNegate : true } ) ; } ) ; } ) . then ( function ( rules ) { return listdir ( dir , rules , dir , true ) ; } ) ; }
Look for .jpmignore in the given directory and use it to filter files
and sub-directories fallback to use default filter rules if .jpmignore
doesn't exist.

@param {String} dir
@param {Object} options
@return {Promise}
Look for . jpmignore in the given directory and use it to filter files and sub - directories fallback to use default filter rules if . jpmignore doesn t exist .