mirror of
https://github.com/atom/atom.git
synced 2026-01-25 23:08:18 -05:00
Port ignore regexps from build-task.coffee
This commit is contained in:
@@ -14,7 +14,6 @@ const CONFIG = require('../config')
|
||||
|
||||
module.exports = function () {
|
||||
console.log(`Running electron-packager on ${CONFIG.intermediateAppPath}`)
|
||||
// https://github.com/electron-userland/electron-packager/blob/master/docs/api.md
|
||||
electronPackager({
|
||||
'app-version': CONFIG.appMetadata.version,
|
||||
'arch': process.arch,
|
||||
@@ -51,59 +50,81 @@ function buildAsarUnpackGlobExpression () {
|
||||
}
|
||||
|
||||
function buildIgnoredPathsRegExp () {
|
||||
const ignoredPaths = [
|
||||
'.DS_Store',
|
||||
'.jshintrc',
|
||||
'.npmignore',
|
||||
'.pairs',
|
||||
'.travis.yml',
|
||||
'appveyor.yml',
|
||||
'.idea',
|
||||
'.editorconfig',
|
||||
'.lint',
|
||||
'.lintignore',
|
||||
'.eslintrc',
|
||||
'.jshintignore',
|
||||
'coffeelint.json',
|
||||
'.coffeelintignore',
|
||||
'.gitattributes',
|
||||
'.gitkeep',
|
||||
path.join('git-utils', 'deps'),
|
||||
path.join('oniguruma', 'deps'),
|
||||
path.join('less', 'dist'),
|
||||
path.join('npm', 'doc'),
|
||||
path.join('npm', 'html'),
|
||||
path.join('npm', 'man'),
|
||||
path.join('npm', 'node_modules', '.bin', 'beep'),
|
||||
path.join('npm', 'node_modules', '.bin', 'clear'),
|
||||
path.join('npm', 'node_modules', '.bin', 'starwars'),
|
||||
path.join('pegjs', 'examples'),
|
||||
path.join('get-parameter-names', 'node_modules', 'testla'),
|
||||
path.join('get-parameter-names', 'node_modules', '.bin', 'testla'),
|
||||
path.join('jasmine-reporters', 'ext'),
|
||||
path.join('jasmine-node', 'node_modules', 'gaze'),
|
||||
path.join('jasmine-node', 'spec'),
|
||||
path.join('node_modules', 'nan'),
|
||||
path.join('node_modules', 'native-mate'),
|
||||
path.join('build', 'binding.Makefile'),
|
||||
path.join('build', 'config.gypi'),
|
||||
path.join('build', 'gyp-mac-tool'),
|
||||
path.join('build', 'Makefile'),
|
||||
path.join('build', 'Release', 'obj.target'),
|
||||
path.join('build', 'Release', 'obj'),
|
||||
path.join('build', 'Release', '.deps'),
|
||||
path.join('vendor', 'apm'),
|
||||
const ignoreRegExps = [
|
||||
escapeRegExp('.DS_Store'),
|
||||
escapeRegExp('.jshintrc'),
|
||||
escapeRegExp('.npmignore'),
|
||||
escapeRegExp('.pairs'),
|
||||
escapeRegExp('.travis.yml'),
|
||||
escapeRegExp('appveyor.yml'),
|
||||
escapeRegExp('.idea'),
|
||||
escapeRegExp('.editorconfig'),
|
||||
escapeRegExp('.lint'),
|
||||
escapeRegExp('.lintignore'),
|
||||
escapeRegExp('.eslintrc'),
|
||||
escapeRegExp('.jshintignore'),
|
||||
escapeRegExp('coffeelint.json'),
|
||||
escapeRegExp('.coffeelintignore'),
|
||||
escapeRegExp('.gitattributes'),
|
||||
escapeRegExp('.gitkeep'),
|
||||
escapeRegExp(path.join('git-utils', 'deps')),
|
||||
escapeRegExp(path.join('oniguruma', 'deps')),
|
||||
escapeRegExp(path.join('less', 'dist')),
|
||||
escapeRegExp(path.join('pegjs', 'examples')),
|
||||
escapeRegExp(path.join('get-parameter-names', 'node_modules', 'testla')),
|
||||
escapeRegExp(path.join('get-parameter-names', 'node_modules', '.bin', 'testla')),
|
||||
escapeRegExp(path.join('jasmine-reporters', 'ext')),
|
||||
escapeRegExp(path.join('node_modules', 'nan')),
|
||||
escapeRegExp(path.join('node_modules', 'native-mate')),
|
||||
escapeRegExp(path.join('build', 'binding.Makefile')),
|
||||
escapeRegExp(path.join('build', 'config.gypi')),
|
||||
escapeRegExp(path.join('build', 'gyp-mac-tool')),
|
||||
escapeRegExp(path.join('build', 'Makefile')),
|
||||
escapeRegExp(path.join('build', 'Release', 'obj.target')),
|
||||
escapeRegExp(path.join('build', 'Release', 'obj')),
|
||||
escapeRegExp(path.join('build', 'Release', '.deps')),
|
||||
escapeRegExp(path.join('vendor', 'apm')),
|
||||
|
||||
// These are only required in dev-mode, when pegjs grammars aren't precompiled
|
||||
path.join('snippets', 'node_modules', 'loophole'),
|
||||
path.join('snippets', 'node_modules', 'pegjs'),
|
||||
path.join('snippets', 'node_modules', '.bin', 'pegjs'),
|
||||
]
|
||||
escapeRegExp(path.join('node_modules', 'loophole')),
|
||||
escapeRegExp(path.join('node_modules', 'pegjs')),
|
||||
escapeRegExp(path.join('node_modules', '.bin', 'pegjs')),
|
||||
escapeRegExp(path.join('node_modules', 'spellchecker', 'vendor', 'hunspell') + path.sep) + '.*',
|
||||
escapeRegExp(path.join('build', 'Release') + path.sep) + '.*\\.pdb',
|
||||
|
||||
const regExpSource = ignoredPaths.map(path => '(' + escapeRegExp(path) + ')').join('|')
|
||||
// Ignore *.cc and *.h files from native modules
|
||||
escapeRegExp(path.join('ctags', 'src') + path.sep) + '.*\\.(cc|h)*',
|
||||
escapeRegExp(path.join('git-utils', 'src') + path.sep) + '.*\\.(cc|h)*',
|
||||
escapeRegExp(path.join('keytar', 'src') + path.sep) + '.*\\.(cc|h)*',
|
||||
escapeRegExp(path.join('nslog', 'src') + path.sep) + '.*\\.(cc|h)*',
|
||||
escapeRegExp(path.join('oniguruma', 'src') + path.sep) + '.*\\.(cc|h)*',
|
||||
escapeRegExp(path.join('pathwatcher', 'src') + path.sep) + '.*\\.(cc|h)*',
|
||||
escapeRegExp(path.join('runas', 'src') + path.sep) + '.*\\.(cc|h)*',
|
||||
escapeRegExp(path.join('scrollbar-style', 'src') + path.sep) + '.*\\.(cc|h)*',
|
||||
escapeRegExp(path.join('spellchecker', 'src') + path.sep) + '.*\\.(cc|h)*',
|
||||
escapeRegExp(path.join('cached-run-in-this-context', 'src') + path.sep) + '.*\\.(cc|h)?',
|
||||
escapeRegExp(path.join('keyboard-layout', 'src') + path.sep) + '.*\\.(cc|h|mm)*',
|
||||
|
||||
// Ignore build files
|
||||
escapeRegExp(path.sep) + 'binding\\.gyp$',
|
||||
escapeRegExp(path.sep) + '.+\\.target.mk$',
|
||||
escapeRegExp(path.sep) + 'linker\\.lock$',
|
||||
escapeRegExp(path.join('build', 'Release') + path.sep) + '.+\\.node\\.dSYM',
|
||||
|
||||
// Ignore test, spec and example folders for packages
|
||||
'node_modules' + escapeRegExp(path.sep) + '.*' + escapeRegExp(path.sep) + '_*te?sts?_*' + escapeRegExp(path.sep),
|
||||
'node_modules' + escapeRegExp(path.sep) + '.*' + escapeRegExp(path.sep) + 'spec' + escapeRegExp(path.sep),
|
||||
'node_modules' + escapeRegExp(path.sep) + '.*' + escapeRegExp(path.sep) + 'examples?' + escapeRegExp(path.sep),
|
||||
]
|
||||
// Ignore Hunspell dictionaries only on macOS.
|
||||
if (process.platform === 'darwin') {
|
||||
ignoreRegExps.push(escapeRegExp(path.join('spellchecker', 'vendor', 'hunspell_dictionaries')))
|
||||
}
|
||||
|
||||
const regExpSource = ignoreRegExps.map(path => `(${path})`).join('|')
|
||||
return new RegExp(regExpSource)
|
||||
}
|
||||
|
||||
function escapeRegExp (string) {
|
||||
string.replace(/[.?*+^$[\]\\(){}|-]/g, "\\$&")
|
||||
return string.replace(/[.?*+^$[\]\\(){}|-]/g, "\\$&")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user