81 lines
3.5 KiB
YAML
81 lines
3.5 KiB
YAML
uuid:
|
|
- value: df8406e6-56bf-4de6-a8e0-64caf5b52058
|
|
langcode:
|
|
- value: en
|
|
type:
|
|
- target_id: daily_email
|
|
target_type: node_type
|
|
target_uuid: 8bde1f2f-eef9-4f2d-ae9c-96921f8193d7
|
|
revision_timestamp:
|
|
- value: '2025-05-11T09:00:44+00:00'
|
|
revision_uid:
|
|
- target_type: user
|
|
target_uuid: b8966985-d4b2-42a7-a319-2e94ccfbb849
|
|
revision_log: { }
|
|
status:
|
|
- value: true
|
|
uid:
|
|
- target_type: user
|
|
target_uuid: b8966985-d4b2-42a7-a319-2e94ccfbb849
|
|
title:
|
|
- value: |
|
|
Automatically running commands with nodemon
|
|
created:
|
|
- value: '2023-04-15T00:00:00+00:00'
|
|
changed:
|
|
- value: '2025-05-11T09:00:44+00:00'
|
|
promote:
|
|
- value: false
|
|
sticky:
|
|
- value: false
|
|
default_langcode:
|
|
- value: true
|
|
revision_translation_affected:
|
|
- value: true
|
|
path:
|
|
- alias: /daily/2023/04/15/automatically-running-commands-with-nodemon
|
|
langcode: en
|
|
body:
|
|
- value: |
|
|
<p>Instead of running the same commands over and over again, some of the command-line tools that I use have a <code>watch</code> mode and will automatically re-run when files are changed, however, not all do.</p>
|
|
|
|
<p>Instead of doing this manually, I can achieve the same thing though using a tool called <code>nodemon</code> - a script monitor for node projects, but it can work with non-node projects too.</p>
|
|
|
|
<p>Here's an example where I'm automatically re-running my PHPUnit tests using a <code>just test</code> recipe each time a file within my custom modules directory changes:</p>
|
|
|
|
<pre><code>nodemon \
|
|
--watch web/modules/custom \
|
|
--ext '*' \
|
|
--exec "just test --stop-on-failure --colors=always"
|
|
</code></pre>
|
|
|
|
<p>I specify the files or directories I want to watch, which file extensions should trigger a restart (in this case, I've enabled all extensions), and the command to execute.</p>
|
|
|
|
<p>This watches all files and run all of the tests, but I can filter either if I need to.</p>
|
|
|
|
<p>As well as PHP tools like PHPUnit and PHPStan, I also use this for other things such as when creating presentation slides with rst2pdf where I can automatically re-generate the PDF whenever I update the rst file.</p>
|
|
|
|
|
|
format: full_html
|
|
processed: |
|
|
<p>Instead of running the same commands over and over again, some of the command-line tools that I use have a <code>watch</code> mode and will automatically re-run when files are changed, however, not all do.</p>
|
|
|
|
<p>Instead of doing this manually, I can achieve the same thing though using a tool called <code>nodemon</code> - a script monitor for node projects, but it can work with non-node projects too.</p>
|
|
|
|
<p>Here's an example where I'm automatically re-running my PHPUnit tests using a <code>just test</code> recipe each time a file within my custom modules directory changes:</p>
|
|
|
|
<pre><code>nodemon \
|
|
--watch web/modules/custom \
|
|
--ext '*' \
|
|
--exec "just test --stop-on-failure --colors=always"
|
|
</code></pre>
|
|
|
|
<p>I specify the files or directories I want to watch, which file extensions should trigger a restart (in this case, I've enabled all extensions), and the command to execute.</p>
|
|
|
|
<p>This watches all files and run all of the tests, but I can filter either if I need to.</p>
|
|
|
|
<p>As well as PHP tools like PHPUnit and PHPStan, I also use this for other things such as when creating presentation slides with rst2pdf where I can automatically re-generate the PDF whenever I update the rst file.</p>
|
|
|
|
|
|
summary: null
|
|
field_daily_email_cta: { }
|