git-checkout.js 574 B

1234567891011121314151617181920
  1. "use strict";
  2. const log = require("npmlog");
  3. const childProcess = require("@lerna/child-process");
  4. module.exports.gitCheckout = gitCheckout;
  5. /**
  6. * Reset files modified by publish steps.
  7. * @param {string[]} stagedFiles
  8. * @param {{ granularPathspec: boolean; }} gitOpts
  9. * @param {import("@lerna/child-process").ExecOpts} execOpts
  10. */
  11. function gitCheckout(stagedFiles, gitOpts, execOpts) {
  12. const files = gitOpts.granularPathspec ? stagedFiles : ".";
  13. log.silly("gitCheckout", files);
  14. return childProcess.exec("git", ["checkout", "--"].concat(files), execOpts);
  15. }