question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ignore does not take globs

See original GitHub issue
  • I have read the contribution documentation for this project.
  • I agree to follow the code of conduct that this project follows, as appropriate.
  • I have searched the issue tracker for an issue that matches the one I want to file, without success.

Please describe your issue: I want to exclude some folders from electron-forge package compilation. The /dist/ folder is mostly empty, followed the instruction https://www.electron.build/file-patterns i want to exclude empty folder /dist/, another not empty folders and some files as follows:

            "electronPackagerConfig": {
                "packageManager": "npm",
                "afterExtract": [
                    "crv/build-scripts/afterExtract.js"
                ],
                "asar":  true,
                "overwrite": true,
                "ignore": [
                    "/apps/",
                    "/dist${/*}",
                    "/libs/",
                    "/out/",
                    "/out-tsc/",
                    "/scripts/",
                    "/styles/",
                    "/themes/",
                    "/angular.json",
                    "/package-lock.json",
                    "/tsconfig.json",
                    "/tslint.json",
                    "/.editorconfig",
                    "/.gitignore",
                    "/README.md"
                ]
            },

The compiler throws an error:

Console output when you run electron-forge with the environment variable DEBUG=electron-forge:*. (Instructions on how to do so here). Please include the stack trace if one exists.

> crv@1.0.0 electron-package-debug-win C:\ZNF_SandBox2\Mvc\StorkCMS\Stork.SPA
> set DEBUG=electron-forge:* & electron-forge package

WARNING: DEBUG environment variable detected.  Progress indicators will be sent over electron-forge:lifecycle
  electron-forge:lifecycle Process Started: Checking your system +0ms
  electron-forge:lifecycle Process Succeeded: Checking your system +2s
  electron-forge:runtime-config setting key: verbose to value: false +0ms
WARNING: DEBUG environment variable detected.  Progress indicators will be sent over electron-forge:lifecycle
  electron-forge:lifecycle Process Started: Preparing to Package Application for arch: x64 +0ms
  electron-forge:project-resolver searching for project in: C:\ZNF_SandBox2\Mvc\StorkCMS\Stork.SPA +0ms
  electron-forge:project-resolver electron-forge compatible package.json found in C:\ZNF_SandBox2\Mvc\StorkCMS\Stork.SPA\package.json +6ms

An unhandled rejection has occurred inside Forge:
Invalid or unexpected token
SyntaxError: Invalid or unexpected token
    at Function (<anonymous>)
    at C:\ZNF_SandBox2\Mvc\StorkCMS\Stork.SPA\node_modules\lodash.template\index.js:1089:12
    at apply (C:\ZNF_SandBox2\Mvc\StorkCMS\Stork.SPA\node_modules\lodash.template\index.js:74:25)
    at C:\ZNF_SandBox2\Mvc\StorkCMS\Stork.SPA\node_modules\lodash.template\index.js:1126:12
    at apply (C:\ZNF_SandBox2\Mvc\StorkCMS\Stork.SPA\node_modules\lodash.template\index.js:76:25)
    at C:\ZNF_SandBox2\Mvc\StorkCMS\Stork.SPA\node_modules\lodash.template\index.js:317:12
    at template (C:\ZNF_SandBox2\Mvc\StorkCMS\Stork.SPA\node_modules\lodash.template\index.js:1088:16)
    at C:\ZNF_SandBox2\Mvc\StorkCMS\Stork.SPA\node_modules\electron-forge\dist\util\forge-config.js:142:46
    at Array.forEach (<anonymous>)
    at template (C:\ZNF_SandBox2\Mvc\StorkCMS\Stork.SPA\node_modules\electron-forge\dist\util\forge-config.js:138:32)
    at C:\ZNF_SandBox2\Mvc\StorkCMS\Stork.SPA\node_modules\electron-forge\dist\util\forge-config.js:140:11
    at Array.forEach (<anonymous>)
    at template (C:\ZNF_SandBox2\Mvc\StorkCMS\Stork.SPA\node_modules\electron-forge\dist\util\forge-config.js:138:32)
    at C:\ZNF_SandBox2\Mvc\StorkCMS\Stork.SPA\node_modules\electron-forge\dist\util\forge-config.js:140:11
    at Array.forEach (<anonymous>)
    at template (C:\ZNF_SandBox2\Mvc\StorkCMS\Stork.SPA\node_modules\electron-forge\dist\util\forge-config.js:138:32)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! crv@1.0.0 electron-package-debug-win: `set DEBUG=electron-forge:* & electron-forge package`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the crv@1.0.0 electron-package-debug-win script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Krzysztof\AppData\Roaming\npm-cache\_logs\2019-06-04T14_20_33_012Z-debug.log

What command line arguments are you passing?

Put the arguments here

What does your config.forge data in package.json look like?

    "config": {
        "forge": {
            "make_targets": {
                "win32": [
                    "squirrel"
                ],
                "darwin": [
                    "zip"
                ],
                "linux": [
                    "deb",
                    "rpm"
                ]
            },
            "electronPackagerConfig": {
                "packageManager": "npm",
                "afterExtract": [
                    "crv/build-scripts/afterExtract.js"
                ],
                "asar":  true,
                "overwrite": true,
                "ignore": [
                    "/apps/",
                    "/dist${/*}",
                    "/libs/",
                    "/out/",
                    "/out-tsc/",
                    "/scripts/",
                    "/styles/",
                    "/themes/",
                    "/angular.json",
                    "/package-lock.json",
                    "/tsconfig.json",
                    "/tslint.json",
                    "/.editorconfig",
                    "/.gitignore",
                    "/README.md"
                ]
            },
            "electronWinstallerConfig": {
                "name": "crv"
            },
            "electronInstallerDebian": {},
            "electronInstallerRedhat": {},
            "github_repository": {
                "owner": "",
                "name": ""
            },
            "windowsStoreConfig": {
                "packageName": "",
                "name": "crv"
            }
        }
    },

Please provide either a failing minimal testcase (with a link to the code) or detailed steps to reproduce your problem. Using electron-forge init is a good starting point, if that is not the source of your problem.

When I change the /dist${/*} part to /dist/** in the config as follow:

                "ignore": [
                    "/apps/",
                    "/dist/**",
                    "/libs/",
                    "/out/",
                    "/out-tsc/",
                    "/scripts/",
                    "/styles/",
                    "/themes/",
                    "/angular.json",
                    "/package-lock.json",
                    "/tsconfig.json",
                    "/tslint.json",
                    "/.editorconfig",
                    "/.gitignore",
                    "/README.md"
                ]
            },

compiler throws the error:

> set DEBUG=electron-forge:* & electron-forge package

WARNING: DEBUG environment variable detected.  Progress indicators will be sent over electron-forge:lifecycle
  electron-forge:lifecycle Process Started: Checking your system +0ms
  electron-forge:lifecycle Process Succeeded: Checking your system +2s
  electron-forge:runtime-config setting key: verbose to value: false +0ms
WARNING: DEBUG environment variable detected.  Progress indicators will be sent over electron-forge:lifecycle
  electron-forge:lifecycle Process Started: Preparing to Package Application for arch: x64 +0ms
  electron-forge:project-resolver searching for project in: C:\ZNF_SandBox2\Mvc\StorkCMS\Stork.SPA +0ms
  electron-forge:project-resolver electron-forge compatible package.json found in C:\ZNF_SandBox2\Mvc\StorkCMS\Stork.SPA\package.json +6ms
  electron-forge:require-search searching [ 'crv/build-scripts/afterExtract.js',
  'C:\\ZNF_SandBox2\\Mvc\\StorkCMS\\Stork.SPA\\crv\\build-scripts\\afterExtract.js',
  'C:\\ZNF_SandBox2\\Mvc\\StorkCMS\\Stork.SPA\\node_modules\\crv\\build-scripts\\afterExtract.js' ] relative to C:\ZNF_SandBox2\Mvc\StorkCMS\Stork.SPA +0ms
  electron-forge:require-search testing crv/build-scripts/afterExtract.js +4ms
  electron-forge:require-search testing C:\ZNF_SandBox2\Mvc\StorkCMS\Stork.SPA\crv\build-scripts\afterExtract.js +2ms
  electron-forge:hook could not find hook: generateAssets +0ms
  electron-forge:hook could not find hook: prePackage +1ms
  electron-forge:packager packaging with options { asar: true,
  overwrite: true,
  packageManager: 'npm',
  afterExtract: [ [Function] ],
  ignore:
   [ '/apps/',
     '/dist/**',
     '/libs/',
     '/out/',
     '/out-tsc/',
     '/scripts/',
     '/styles/',
     '/themes/',
     '/angular.json',
     '/package-lock.json',
     '/tsconfig.json',
     '/tslint.json',
     '/.editorconfig',
     '/.gitignore',
     '/README.md' ],
  afterCopy: [ [Function] ],
  afterPrune: [ [Function] ],
  dir: 'C:\\ZNF_SandBox2\\Mvc\\StorkCMS\\Stork.SPA',
  arch: 'x64',
  platform: 'win32',
  out: 'C:\\ZNF_SandBox2\\Mvc\\StorkCMS\\Stork.SPA\\out',
  electronVersion: '4.0.0',
  quiet: true } +0ms
Database successfully copied!

An unhandled rejection has occurred inside Forge:
Invalid regular expression: //dist/**/: Nothing to repeat
SyntaxError: Invalid regular expression: //dist/**/: Nothing to repeat
    at String.match (<anonymous>)
    at ignore.some.regex (C:\ZNF_SandBox2\Mvc\StorkCMS\Stork.SPA\node_modules\electron-packager\ignore.js:65:41)
    at Array.some (<anonymous>)
    at filterByRegexes (C:\ZNF_SandBox2\Mvc\StorkCMS\Stork.SPA\node_modules\electron-packager\ignore.js:65:22)
    at Object.filter (C:\ZNF_SandBox2\Mvc\StorkCMS\Stork.SPA\node_modules\electron-packager\ignore.js:83:12)
    at handleFilter (C:\ZNF_SandBox2\Mvc\StorkCMS\Stork.SPA\node_modules\electron-packager\node_modules\fs-extra\lib\copy\copy.js:60:24)
    at Object.copy (C:\ZNF_SandBox2\Mvc\StorkCMS\Stork.SPA\node_modules\electron-packager\node_modules\fs-extra\lib\copy\copy.js:38:27)
    at Promise (C:\ZNF_SandBox2\Mvc\StorkCMS\Stork.SPA\node_modules\universalify\index.js:13:12)
    at new Promise (<anonymous>)
    at Object.copy (C:\ZNF_SandBox2\Mvc\StorkCMS\Stork.SPA\node_modules\universalify\index.js:7:14)
    at WindowsApp.copyTemplate (C:\ZNF_SandBox2\Mvc\StorkCMS\Stork.SPA\node_modules\electron-packager\platform.js:102:15)
    at fs.move.then (C:\ZNF_SandBox2\Mvc\StorkCMS\Stork.SPA\node_modules\electron-packager\platform.js:90:24)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! crv@1.0.0 electron-package-debug-win: `set DEBUG=electron-forge:* & electron-forge package`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the crv@1.0.0 electron-package-debug-win script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Krzysztof\AppData\Roaming\npm-cache\_logs\2019-06-04T14_33_31_882Z-debug.log

How to exclude empty folders?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

8reactions
kzimnycommented, Jun 5, 2019

Thank you very much for your help. My final solution looks as follow:

                "ignore": [
                    "^(\/apps$)",
                    "^(\/dist$)",
                    "^(\/libs$)",
                    "^(\/out$)",
                    "^(\/out-tsc$)",
                    "^(\/scripts$)",
                    "^(\/styles$)",
                    "^(\/themes$)",
                    ".editorconfig",
                    ".gitignore",
                    "angular.json",
                    "package-lock.json",
                    "^(\/README.md$)",
                    "Stork.SPA.njsproj",
                    "Stork.SPA.njsproj.user",
                    "tsconfig.json",
                    "tslint.json"
                ]

It’s important to take only the first folder in the hierarchy, otherwise all folders with the same name in node_modules are ignored. It was the big mistake in my attempts.

3reactions
maleptcommented, Jun 4, 2019

followed the instruction https://www.electron.build/file-patterns

First off, that website is for electron-builder, not Electron Forge.

Secondly, per the Electron Packager API docs, ignore takes RegExps, not globs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ignore does not take globs · Issue #909 · electron/forge - GitHub
I have searched the issue tracker for an issue that matches the one I want to file, without success. Please describe your issue:...
Read more >
git - Gitignore glob path - Stack Overflow
You should not ignore any directories or it will not look into these directories to include .js files under them again.
Read more >
Ignore Files In Gitignore Using Globbing Patterns - Pavol Kutaj
The concern is documenting how to ignore files in a git project with a .gitignore file using so called globbing pattens (aka standard...
Read more >
gitignore Documentation - Git
DESCRIPTION. A gitignore file specifies intentionally untracked files that Git should ignore. Files already tracked by Git are not affected; see the NOTES ......
Read more >
Ignoring Code - Prettier
Use .prettierignore to ignore (i.e. not reformat) certain files and folders completely. Use “prettier-ignore” comments to ignore parts of files.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found