Easier Sculpin Commands with Composer and NPM Scripts

In this video, I show you how I've simplified my Sculpin and Gulp workflow using custom Composer and NPM scripts.

My website includes several various command line tools - e.g. Sculpin, Gulp and Behat - each needing different arguments and options, depending on the command being run. For example, for Sculpin, I normally include several additional options when viewing the site locally - the full command that I use is ./vendor/bin/sculpin generate --watch --server --clean --no-interaction. Typing this repeatedly is time consuming and could be easily mis-typed, forgotten or confused with other commands.

In this video, I show you how I've simplified my Sculpin and Gulp workflow using custom Composer and NPM scripts.

Scripts

Here are the scripts that I'm using - they are slightly different from those in the video. I use the --generate and --watch options for Sculpin and the gulp watch command for NPM. I had to change these before the recording as I was using the demo magic script to run the commands, and existing from a watch session was also ending the script process.

composer.json

"scripts": {
"clean": "rm -rf output_*/",
"dev": "sculpin generate --clean --no-interaction --server --watch",
"production": "sculpin generate --clean --no-interaction --env='prod' --quiet"
}

Run with composer run <name>, e.g. composer run dev.

package.json

"scripts": {
"init": "yarn && bower install",
"dev": "gulp watch",
"production": "gulp --production"
}

Run with npm run <name>, e.g. npm run production.

You can also take a look at the full composer.json and package.json files within my site repository on GitHub.

Resources

Composer scripts

oliverdavies.uk composer.json

oliverdavies.uk package.json