Remark: Remark fails when used in lint-staged pre-commit hook

Created on 3 Dec 2019  路  2Comments  路  Source: remarkjs/remark

Remark fails when used in pre-commit hook

Remark fails when used in combination with lint-staged package for multiple .md files with error:

Error: Cannot write multiple files to single output: [path-to-local-repo]\1.md
  at done ([path-to-node-modules]\unified-engine\lib\file-pipeline\copy.js:63:9)
  at onstatfile ([path-to-node-modules]\unified-engine\lib\file-pipeline\copy.js:46:7)
  at FSReqCallback.oncomplete (fs.js:159:5)

When running outside the coomit hook (npm run md:fix), remark works as expected.

Your environment

  • OS: WIN 10
  • Packages: see package.json in included minimal reproduction
  • Env: node 12.13.0

Steps to reproduce

  1. clone the repo https://github.com/jpohancenik/remark-lint-issue
  2. run npm i to install packages
  3. make some invalid changes in 1.md and 2.m (e.g. multiple empty lines between text)
  4. stash the files git add .
  5. commit the files git commit -m test
  6. see the error in console

minimal reproduction: https://github.com/jpohancenik/remark-lint-issue

Expected behaviour

Remark should write fixes to output files without throwing error.

Actual behaviour

Remark fails with error message Cannot write multiple files to single output

馃檵 typquestion

Most helpful comment

You can fix this if you add -- to the end of your script, like so: remark . -o --.
This feature, which many other commands also support, says to not parse further values (which lint-staged passes) as arguments, but instead as files!

All 2 comments

You can fix this if you add -- to the end of your script, like so: remark . -o --.
This feature, which many other commands also support, says to not parse further values (which lint-staged passes) as arguments, but instead as files!

Thank you, works like a charm!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

KyleAMathews picture KyleAMathews  路  6Comments

rauschma picture rauschma  路  4Comments

fisker picture fisker  路  4Comments

wooorm picture wooorm  路  4Comments

niksurff picture niksurff  路  4Comments