This repository has been archived on 2025-01-19. You can view files and clone it, but cannot push or open issues or pull requests.
oliverdavies.uk-old-sculpin/source/_posts/easier-sculpin-commands-with-composer-and-npm-scripts.md

65 lines
2.5 KiB
Markdown
Raw Normal View History

2017-01-08 01:45:07 +00:00
---
title: Easier Sculpin Commands with Composer and NPM Scripts
2018-06-02 10:58:39 +00:00
date: '2017-01-07'
2017-01-08 01:45:07 +00:00
tags: [composer, gulp, sculpin]
2017-01-08 08:41:24 +00:00
use: [posts]
2017-01-08 01:45:07 +00:00
---
{% block excerpt %}
In this video, I show you how I've simplied my Sculpin and Gulp workflow using custom Composer and NPM scripts.
{% endblock %}
{% block content %}
My website includes several various command line tools - e.g. [Sculpin][4], [Gulp][5] and [Behat][6] - 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 simplied my Sculpin and Gulp workflow using custom Composer and NPM scripts.
<div class="embed-container">
2017-01-08 08:09:21 +00:00
<iframe width="560" height="315" src="https://www.youtube.com/embed/eiWDV_63yCQ" frameborder="0" allowfullscreen></iframe>
2017-01-08 01:45:07 +00:00
</div>
## Scripts
Here are the scripts that Im 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][0] script to run the commands, and existing from a watch session was also ending the script process.
### composer.json
2017-03-16 08:09:52 +00:00
```language-json
2017-01-08 01:45:07 +00:00
"scripts": {
"clean": "rm -rf output_*/",
"dev": "sculpin generate --clean --no-interaction --server --watch",
2017-01-08 08:09:21 +00:00
"production": "sculpin generate --clean --no-interaction --env='prod' --quiet"
2017-01-08 01:45:07 +00:00
}
```
Run with `composer run <name>`, e.g. `composer run dev`.
2017-12-10 23:38:49 +00:00
2017-01-08 01:45:07 +00:00
### package.json
2017-03-16 08:09:52 +00:00
```language-json
2017-01-08 01:45:07 +00:00
"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][1] and [package.json][2] files within my site repository on [GitHub][3].
## Resources
- [Composer scripts][7]
- [oliverdavies.uk composer.json][1]
- [oliverdavies.uk package.json][2]
{% endblock %}
[0]: https://github.com/paxtonhare/demo-magic
[1]: https://github.com/opdavies/oliverdavies.uk/blob/master/composer.json
[2]: https://github.com/opdavies/oliverdavies.uk/blob/master/package.json
[3]: https://github.com/opdavies/oliverdavies.uk
[4]: https://sculpin.io
[5]: http://gulpjs.com
[6]: http://behat.org
[7]: https://getcomposer.org/doc/04-schema.md#scripts