0

My source folder is /dist, and I want to run a NW.js script in /tool/nw.js. Why does it throw the glob pattern error about not finding the srcDir (/dist) folder? It works when using glob:false in the config but I want to know why the srcDir: "../dist" is wrong.

My folder structure

/
  /build

  /dist
      /html
      package.json

  /tool
    run.js
 

/tool/run.js

    await nwbuild({
      platform: "linux",
      arch: "x64",
      srcDir: "../dist",
      outDir: "../build/linux64",
      glob: true // true by default
    });
1
  • 1
    My assumption is it is related to the Current Working Directory (process.cwd()). If you are using common js (require instead of import), then you could use const path = require('path'); and path.join(__dirname, '../dist') to make the path relative to the current file. Commented Jul 9, 2024 at 3:50

1 Answer 1

1

If globbing is enabled and you set srcDir to ../dist, then nw-builder will only "glob" the ../dist directory without going through its contents.

To get all files and folders: ../dist/**/*.*

To get files and folders one level deep: ../dist/*

To learn more about file globbing: https://github.com/isaacs/node-glob?tab=readme-ov-file#glob-primer

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.