Skip to content

Use "node --run" instead of "npm run" #3764

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,31 @@ We hold our code to standard, and these standards are documented below.

We use [prettier](https://prettier.io/) for automatic formatting a lot all our files. The configuration is in our `prettier.config.mjs` file.

To run prettier, use `npm run lint:prettier`.
To run prettier, use `node --run lint:prettier`.

### JavaScript: Run ESLint

We use [ESLint](https://eslint.org) to lint our JavaScript files. The configuration is in our `eslint.config.mjs` file.

To run ESLint, use `npm run lint:js`.
To run ESLint, use `node --run lint:js`.

### CSS: Run StyleLint

We use [StyleLint](https://stylelint.io) to lint our CSS. The configuration is in our `.stylelintrc.json` file.

To run StyleLint, use `npm run lint:css`.
To run StyleLint, use `node --run lint:css`.

### Markdown: Run markdownlint

We use [markdownlint-cli2](https://github.com/DavidAnson/markdownlint-cli2) to lint our markdown files. The configuration is in our `.markdownlint.json` file.

To run markdownlint, use `npm run markdownlint:css`.
To run markdownlint, use `node --run markdownlint:css`.

## Testing

We use [Jest](https://jestjs.io) for JavaScript testing.

To run all tests, use `npm run test`.
To run all tests, use `node --run test`.

The specific test commands are defined in `package.json`.
So you can also run the specific tests with other commands, e.g. `npm run test:unit` or `npx jest tests/e2e/env_spec.js`.
So you can also run the specific tests with other commands, e.g. `node --run test:unit` or `npx jest tests/e2e/env_spec.js`.
10 changes: 5 additions & 5 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ body:
description: |
Please keep in mind that some problems are specific to certain start options.
options:
- "npm run start"
- "npm run start:wayland"
- "npm run start:windows"
- "npm run start:x11"
- "npm run server"
- "node --run start"
- "node --run start:wayland"
- "node --run start:windows"
- "node --run start:x11"
- "node --run server"
- "node clientonly --address ... --port ..."
validations:
required: true
Expand Down
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Hello and thank you for wanting to contribute to the MagicMirror² project!
> - What does the pull request accomplish? Use a list if needed.
> - If it includes major visual changes please add screenshots.
>
> 3. Please run `npm run lint:prettier` before submitting so that
> 3. Please run `node --run lint:prettier` before submitting so that
> style issues are fixed.
> 4. Don't forget to add an entry about your changes to
> the CHANGELOG.md file.
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/automated-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ jobs:
cache: "npm"
- name: "Install dependencies"
run: |
npm run install-mm:dev
node --run install-mm:dev
- name: "Run linter tests"
run: |
npm run test:prettier
npm run test:js
npm run test:css
npm run test:markdown
node --run test:prettier
node --run test:js
node --run test:css
node --run test:markdown
test:
runs-on: ubuntu-24.04
timeout-minutes: 30
Expand All @@ -54,7 +54,7 @@ jobs:
cache: "npm"
- name: "Install MagicMirror²"
run: |
npm run install-mm:dev
node --run install-mm:dev
- name: "Run tests"
run: |
# Fix chrome-sandbox permissions:
Expand All @@ -64,4 +64,4 @@ jobs:
WLR_BACKENDS=headless WLR_LIBINPUT_NO_DEVICES=1 WLR_RENDERER=pixman labwc &
export WAYLAND_DISPLAY=wayland-0
touch css/custom.css
npm run test
node --run test
2 changes: 1 addition & 1 deletion .github/workflows/electron-rebuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
node-version: ${{ matrix.node-version }}
check-latest: true
- name: Install MagicMirror
run: npm run install-mm
run: node --run install-mm
- name: Install @electron/rebuild
run: npm install @electron/rebuild
- name: Install node-libgpiod deps
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/spellcheck.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ jobs:
cache: "npm"
- name: Install dependencies
run: |
npm run install-mm:dev
node --run install-mm:dev
- name: Run Spellcheck
run: npm run test:spelling
run: node --run test:spelling
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,7 @@ Temporary Items

# Ignore positions file (#3518)
js/positions.js

# Ignore lock files other than package-lock.json
pnpm-lock.yaml
yarn.lock
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ planned for 2025-07-01

### Changed

- [refactor] Simplify module loading process
- [refactor] Simplify module loading process (#3766)
- Use "node --run" instead of "npm run" (#1511)

## [2.31.0] - 2025-04-01

Expand All @@ -34,7 +35,7 @@ Thanks to: @Developer-Incoming, @eltociear, @geraki, @khassel, @KristjanESPERANT

### Changed

- [core] starting clientonly now checks for needed env var `WAYLAND_DISPLAY` or `DISPLAY` and starts electron with needed parameters (if both are set wayland is used) (#3677)
- [core] Starting clientonly now checks for needed env var `WAYLAND_DISPLAY` or `DISPLAY` and starts electron with needed parameters (if both are set wayland is used) (#3677)
- [core] Optimize systeminformation calls and output (#3689)
- [core] Add issue templates for feature requests and bug reports (#3695)
- [core] Adapt `start:x11:dev` script
Expand Down
2 changes: 1 addition & 1 deletion js/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const defaults = {
position: "middle_center",
classes: "xsmall",
config: {
text: "If you get this message while your config file is already created,<br>" + "it probably contains an error. To validate your config file run in your MagicMirror² directory<br>" + "<pre>npm run config:check</pre>"
text: "If you get this message while your config file is already created,<br>" + "it probably contains an error. To validate your config file run in your MagicMirror² directory<br>" + "<pre>node --run config:check</pre>"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion js/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function createWindow () {
const port = process.env.MM_PORT || config.port;
mainWindow.loadURL(`${prefix}${address}:${port}`);

// Open the DevTools if run with "npm start dev"
// Open the DevTools if run with "node --run start:dev"
if (process.argv.includes("dev")) {
if (process.env.JEST_WORKER_ID !== undefined) {
// if we are running with jest
Expand Down
10 changes: 5 additions & 5 deletions modules/default/updatenotification/update_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@ class Updater {
});
}

// restart rules (pm2 or npm start)
// restart rules (pm2 or node --run start)
restart () {
if (this.usePM2) this.pm2Restart();
else this.npmRestart();
else this.nodeRestart();
}

// restart MagicMiror with "pm2": use PM2Id for restart it
Expand All @@ -150,12 +150,12 @@ class Updater {
});
}

// restart MagicMiror with "npm start"
npmRestart () {
// restart MagicMiror with "node --run start"
nodeRestart () {
Log.info("updatenotification: Restarting MagicMirror...");
const out = process.stdout;
const err = process.stderr;
const subprocess = Spawn("npm start", { cwd: this.root_path, shell: true, detached: true, stdio: ["ignore", out, err] });
const subprocess = Spawn("node --run start", { cwd: this.root_path, shell: true, detached: true, stdio: ["ignore", out, err] });
subprocess.unref(); // detach the newly launched process from the master process
process.exit();
}
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@
"lint:js": "eslint --fix",
"lint:markdown": "markdownlint-cli2 . --fix",
"lint:prettier": "prettier . --write",
"postinstall": "npm run install-vendor && npm run install-fonts && echo \"MagicMirror² installation finished successfully! \n\"",
"postinstall": "node --run install-vendor && node --run install-fonts && echo \"MagicMirror² installation finished successfully! \n\"",
"prepare": "[ -f node_modules/.bin/husky ] && husky || echo no husky installed.",
"server": "node ./serveronly",
"start": "npm run start:x11",
"start:dev": "npm run start -- dev",
"start": "node --run start:x11",
"start:dev": "node --run start -- dev",
"start:wayland": "WAYLAND_DISPLAY=\"${WAYLAND_DISPLAY:=wayland-1}\" ./node_modules/.bin/electron js/electron.js --enable-features=UseOzonePlatform --ozone-platform=wayland",
"start:wayland:dev": "npm run start:wayland -- dev",
"start:wayland:dev": "node --run start:wayland -- dev",
"start:windows": ".\\node_modules\\.bin\\electron js\\electron.js",
"start:windows:dev": "npm run start:windows -- dev",
"start:windows:dev": "node --run start:windows -- dev",
"start:x11": "DISPLAY=\"${DISPLAY:=:0}\" ./node_modules/.bin/electron js/electron.js",
"start:x11:dev": "npm run start:x11 -- dev",
"start:x11:dev": "node --run start:x11 -- dev",
"test": "NODE_ENV=test jest -i --forceExit",
"test:calendar": "node ./modules/default/calendar/debug.js",
"test:coverage": "NODE_ENV=test jest --coverage -i --verbose false --forceExit",
Expand Down