Skip to content
This repository has been archived by the owner on Nov 29, 2021. It is now read-only.

Commit

Permalink
Test/Fix OSX on Travis
Browse files Browse the repository at this point in the history
It looks like the OSX version of `nc` doesn't support the `-q` flag,
so prettier_dnc needs to check nc, and the tests shouldn't use nc directly.
  • Loading branch information
josephfrazier committed Jul 8, 2017
1 parent 93def94 commit 610231c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 1,6 @@
os:
- linux
- osx
language: node_js
node_js:
- node
Expand All @@ -6,3 9,6 @@ cache:
yarn: true
directories:
- "node_modules"
- $HOME/Library/Caches/Homebrew # https://stackoverflow.com/questions/39930171/cache-brew-builds-with-travis-ci/41386136#41386136
before_install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install md5sha1sum; fi
6 changes: 5 additions & 1 deletion bin/prettier_dnc.sh
Original file line number Diff line number Diff line change
@@ -1,4 1,8 @@
#!/usr/bin/env bash
PORT=`cat ~/.prettier_d | cut -d" " -f1`
TOKEN=`cat ~/.prettier_d | cut -d" " -f2`
cat <(echo "$TOKEN $PWD --stdin $@") - | nc -q 0 localhost $PORT
if nc 2>&1 | grep -- -q >/dev/null; then
cat <(echo "$TOKEN $PWD --stdin $@") - | nc -q 0 localhost $PORT
else
cat <(echo "$TOKEN $PWD --stdin $@") - | nc localhost $PORT
fi
5 changes: 1 addition & 4 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 19,6 @@ TOKEN=`cat ~/.prettier_d | cut -d" " -f2`
md5sum $file | grep f75b2b44fd861a20b69f9a3e1960e419 >/dev/null

# Format it using netcat and make sure the output has been formatted
echo "$TOKEN $PWD $file" | nc -q 0 localhost $PORT | md5sum | grep 750573a1ced7ec47055a51584e1fcd6e >/dev/null

# Pipe it to netcat and get the same output
cat $file | $prettier_dnc | md5sum | grep 750573a1ced7ec47055a51584e1fcd6e >/dev/null

# Ensure that --list-different prints the filename
Expand All @@ -48,6 45,6 @@ echo '{"key":"value"}' | $prettier_dnc --json | md5sum | grep c482e72bc3892b16a4
$prettier --json p.json | md5sum | grep faa3eb7c97ed871f63ec955b9498dee4 >/dev/null

# Verify that multiple files are currently not supported
echo "$TOKEN $PWD $file $file" | nc -q 0 localhost $PORT | md5sum | grep 750573a1ced7ec47055a51584e1fcd6e >/dev/null
$prettier $file $file | md5sum | grep 750573a1ced7ec47055a51584e1fcd6e >/dev/null

popd >/dev/null

0 comments on commit 610231c

Please sign in to comment.