anglepoised

Codeship and curly bracket expansion

This isn’t an issue with Codeship as such, but it can affect it.

I had a task in an npm script that created some directories for a couple of cli tools that (for whatever reason) expected directories to be present but wouldn’t create them:

"copy": "mkdir -p dist/{dir1,dir2}",

This task worked locally (on OS X El Capitan) but the first time I tried to build on Codeship, my tests failed.

Working out why was pretty straightforward. Codeship images use Ubuntu. Ubuntu uses dash rather than bash for /bin/sh

$ ls -l /bin/sh
lrwxrwxrwx 1 root root 4 Feb 19  2014 /bin/sh -> dash

…and of course, dash doesn’t support curly bracket expansion. Huh. Who knew?

There wasn’t much point spending time on such a simple line, so I went with the cheap fix of listing out each mkdir in long form:

"copy": "mkdir -p dist/dir1 && mkdir -p dist/dir2",

I need to remember that:

  1. Avoiding fancy stuff is sensible (curly bracket expansion isn’t particularly fancy, but it wasn’t exactly saving me a great deal of effort, either).
  2. Subtle cross-platform issues crop up all over the place. Using Vagrant, Docker or Otto for consistent development, stage, CI and production environments is a good idea where time allows.
  3. Running tests on a range of platforms is worthwhile. Time to get up and running with Appveyor, I think.

I like using npm as a build tool, but keep coming across niggling issues like this.