diff --git a/README.md b/README.md index dcd7b727f..6c93e734f 100644 --- a/README.md +++ b/README.md @@ -228,10 +228,10 @@ time. ```bash PORT=`cat ~/.prettier_d | cut -d" " -f1` TOKEN=`cat ~/.prettier_d | cut -d" " -f2` -echo "$TOKEN $PWD file.js" | nc -q 0 localhost $PORT +echo "$TOKEN $PWD file.js" | nc -q 0 127.0.0.1 $PORT # You can also pipe a stream in with `--stdin`: -cat file.js | cat <(echo "$TOKEN $PWD --stdin") - | nc -q 0 localhost $PORT +cat file.js | cat <(echo "$TOKEN $PWD --stdin") - | nc -q 0 127.0.0.1 $PORT # `prettier_dnc` is provided as a helper script for this usage: cat file.js | prettier_dnc ``` diff --git a/bin/prettier_dnc.sh b/bin/prettier_dnc.sh index 54176da4e..aa9f57538 100755 --- a/bin/prettier_dnc.sh +++ b/bin/prettier_dnc.sh @@ -1,8 +1,11 @@ #!/usr/bin/env bash -PORT=`cat ~/.prettier_d | cut -d" " -f1` -TOKEN=`cat ~/.prettier_d | cut -d" " -f2` + +IFS=' ' read PORT TOKEN < ~/.prettier_d + if nc 2>&1 | grep -- -q >/dev/null; then - cat <(echo "$TOKEN $PWD --stdin $@") - | nc -q 0 localhost $PORT + NC_OPTIONS="-q 0" else - cat <(echo "$TOKEN $PWD --stdin $@") - | nc localhost $PORT + NC_OPTIONS="" fi + +cat <(echo "$TOKEN $PWD --stdin $@") - | nc $NC_OPTIONS 127.0.0.1 $PORT diff --git a/lib/client.js b/lib/client.js index c703639e5..23be4db86 100644 --- a/lib/client.js +++ b/lib/client.js @@ -10,7 +10,7 @@ function connect(callback) { return callback(Error('Not running')) } net - .connect(data.port, function() { + .connect(data.port, '127.0.0.1', function() { callback(null, this, data.token) }) .on('error', () => { diff --git a/lib/options.js b/lib/options.js index 3b7fc66b9..e97b73b73 100644 --- a/lib/options.js +++ b/lib/options.js @@ -12,7 +12,7 @@ module.exports.generateHelp = function() { prettierPath, '--help', '| sed "s/Usage: prettier/Usage: prettier_d/"', - '| sed "s/filename .../filename/"', + '| sed "s/file\\/glob .../filename/"', '| grep -v -- --color', ].join(' ') const prettierHelp = cp.execSync(prettierHelpCommand).toString() diff --git a/package.json b/package.json index f905ac5c4..e44683dee 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "prettier_d", - "version": "5.7.3", + "version": "5.7.4", "description": "Makes prettier the fastest formatter on the planet", "bin": { "prettier_d": "bin/prettier_d.js", diff --git a/test.sh b/test.sh index ee3869e6c..04ab8d4fb 100755 --- a/test.sh +++ b/test.sh @@ -29,7 +29,7 @@ tmp=.write.test.js cp $file $tmp && $prettier --write $tmp && $prettier --list-different $tmp | wc -c | grep '\<0$' >/dev/null && rm $tmp # Ensure help message shows prettier_d and only one filename -$prettier --help | grep "Usage: prettier_d .opts. .filename.$" >/dev/null +$prettier --help | grep "Usage: prettier_d .options. .filename.$" >/dev/null # Ensure --fallback is in the help message $prettier --help | grep -- "--fallback" >/dev/null diff --git a/yarn.lock b/yarn.lock index 8e9cbde1e..51df3b0e3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -216,9 +216,9 @@ cross-spawn@^5.1.0: shebang-command "^1.2.0" which "^1.2.9" -debug@^2.6.8: - version "2.6.8" - resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.8.tgz#e731531ca2ede27d188222427da17821d68ff4fc" +debug@^3.0.1: + version "3.1.0" + resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" dependencies: ms "2.0.0" @@ -264,11 +264,11 @@ escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5: resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" eslint-plugin-prettier@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-2.2.0.tgz#f2837ad063903d73c621e7188fb3d41486434088" + version "2.3.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-2.3.1.tgz#e7a746c67e716f335274b88295a9ead9f544e44d" dependencies: fast-diff "^1.1.1" - jest-docblock "^20.0.1" + jest-docblock "^21.0.0" eslint-scope@^3.7.1: version "3.7.1" @@ -278,18 +278,18 @@ eslint-scope@^3.7.1: estraverse "^4.1.1" eslint@^4.5.0: - version "4.5.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-4.5.0.tgz#bb75d3b8bde97fb5e13efcd539744677feb019c3" + version "4.8.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-4.8.0.tgz#229ef0e354e0e61d837c7a80fdfba825e199815e" dependencies: ajv "^5.2.0" babel-code-frame "^6.22.0" chalk "^2.1.0" concat-stream "^1.6.0" cross-spawn "^5.1.0" - debug "^2.6.8" + debug "^3.0.1" doctrine "^2.0.0" eslint-scope "^3.7.1" - espree "^3.5.0" + espree "^3.5.1" esquery "^1.0.0" estraverse "^4.2.0" esutils "^2.0.2" @@ -310,7 +310,7 @@ eslint@^4.5.0: natural-compare "^1.4.0" optionator "^0.8.2" path-is-inside "^1.0.2" - pluralize "^4.0.0" + pluralize "^7.0.0" progress "^2.0.0" require-uncached "^1.0.3" semver "^5.3.0" @@ -319,9 +319,9 @@ eslint@^4.5.0: table "^4.0.1" text-table "~0.2.0" -espree@^3.5.0: - version "3.5.0" - resolved "https://registry.yarnpkg.com/espree/-/espree-3.5.0.tgz#98358625bdd055861ea27e2867ea729faf463d8d" +espree@^3.5.1: + version "3.5.1" + resolved "https://registry.yarnpkg.com/espree/-/espree-3.5.1.tgz#0c988b8ab46db53100a1954ae4ba995ddd27d87e" dependencies: acorn "^5.1.1" acorn-jsx "^3.0.0" @@ -533,9 +533,9 @@ isexe@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" -jest-docblock@^20.0.1: - version "20.0.3" - resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-20.0.3.tgz#17bea984342cc33d83c50fbe1545ea0efaa44712" +jest-docblock@^21.0.0: + version "21.2.0" + resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-21.2.0.tgz#51529c3b30d5fd159da60c27ceedc195faf8d414" js-tokens@^3.0.2: version "3.0.2" @@ -693,17 +693,17 @@ pinkie@^2.0.0: version "2.0.4" resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870" -pluralize@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-4.0.0.tgz#59b708c1c0190a2f692f1c7618c446b052fd1762" +pluralize@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-7.0.0.tgz#298b89df8b93b0221dbf421ad2b1b1ea23fc6777" prelude-ls@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" prettier@^1.5.3: - version "1.5.3" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.5.3.tgz#59dadc683345ec6b88f88b94ed4ae7e1da394bfe" + version "1.7.4" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.7.4.tgz#5e8624ae9363c80f95ec644584ecdf55d74f93fa" process-nextick-args@~1.0.6: version "1.0.7" @@ -853,12 +853,18 @@ supports-color@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" -supports-color@^4.0.0, supports-color@^4.2.1: +supports-color@^4.0.0: version "4.2.1" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-4.2.1.tgz#65a4bb2631e90e02420dba5554c375a4754bb836" dependencies: has-flag "^2.0.0" +supports-color@^4.2.1: + version "4.4.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-4.4.0.tgz#883f7ddabc165142b2a61427f3352ded195d1a3e" + dependencies: + has-flag "^2.0.0" + table@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/table/-/table-4.0.1.tgz#a8116c133fac2c61f4a420ab6cdf5c4d61f0e435"