Skip to content

Instantly share code, notes, and snippets.

@daikiojm
Created March 26, 2018 01:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daikiojm/09c3d659206fcc4a98f01ecf256b9736 to your computer and use it in GitHub Desktop.
Save daikiojm/09c3d659206fcc4a98f01ecf256b9736 to your computer and use it in GitHub Desktop.
git_command_in_node
const { spawn } = require('child_process');
const ls = spawn('git', ['rev-parse', 'HEAD']);
ls.stdout.setEncoding('utf-8').on('data', (data) => {
const res = data.replace(/\r?\n|\r\n/g, '');
console.log(`${res}`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment