Codux Help Center
Browse our articles to find the answers you need
Understanding and Running Project Scripts
For the average non-developer, running scripts through commands in the terminal can be an intimidating, potentially dangerous place. The scripts feature in Codux makes it easy for you and all users — designers, developers, and everyone in between, to run premade scripts directly from the UI without having to enter any actual commands.
This article explains why scripts are necessary and how they can be run in Codux. If you are a developer interested in configuring scripts in a project's configuration file, or in having a script run in response to a trigger, refer to Configuring Project Scripts.
Why Run Scripts?
If Codux is meant to make component design and testing easy, why are scripts necessary? Scripts come in handy for a wide range of reasons throughout a workflow. For example, a script can turn a project into an app for production, or satisfy a project's dependencies (installing/importing other pieces of code that are needed to make everything work).
Scripts are necessary, and Codux makes it easy for all users to access and run those that were made specifically for the project. Developers can also set scripts to trigger automatically in response to certain triggers like when you've cloned the project, pulled changes, or switched branches. Refer to Syncing Projects with Git for more information.
If you see a popup asking you to run a script, there is a good chance that it appeared due to a trigger set by a developer, or because it has been hard-coded to do so in Codux. Just run the script, and you'll be all set! To see what this popup looks like, read on.
Manually Run Scripts
To manually run a script, click on the Scripts side panel tab in the bottom left corner of Codux. Then choose the script from one of these categories in the Scripts panel:
- Configured Scripts: Configured scripts are scripts that were defined in the project's configuration file (codux.config.json). They can be individual scripts, or batch scripts with multiple individual scripts that run in a specified order.
- Package JSON Scripts: Scripts defined in the project's package.json file (every project has one of these. It is in charge of storing the project's metadata and inventorying the project's dependencies, among other purposes.
After making your selection, an overlay will show. Select Run to get the script going.
When the script finishes, you'll see a confirmation message like this one:
If it didn't complete successfully, you'll also know about that. Running scripts can sometimes fail for any number of reasons related to the project, your machine, or a combination of both. You'll have the option to retry running the failed script. If the retry fails too, copy the error message and consult with the project owner.
Important!
Codux can only install packages listed in the project's package.json file if you have the proper permissions to access them. If the installation fails, one thing you could do is check that you're logged into npmjs.org in your terminal by running the command
npm whoami
. Refer here for more information.Run Scripts in the Background
To run scripts in the background, just click the Run in Background button in the scripts dialog window, and continue on your way. You'll see an indicator that the script is still running in and on the Scripts panel tab.
When the script(s) finish running in the background, you'll see a toast notification to let you know.
Was this article helpful?