Comparing version 1.2.0 to 1.2.1
@@ -8,5 +8,5 @@ #!/usr/bin/env node | ||
const chalk = require("chalk"); | ||
const exec = require("child_process").exec; | ||
const { exec } = require("child_process"); | ||
let examples = [ | ||
const examples = [ | ||
"2010", | ||
@@ -23,6 +23,6 @@ "Tuesday May 25th, 2010", | ||
let exit = err => { | ||
function exit(err) { | ||
if (err) console.log(chalk`{red error: ${err}}`); | ||
console.log(`usage: git date <date string>\n\nExamples of valid commands:`); | ||
console.log("usage: git date <date string>\n\nExamples of valid commands:"); | ||
examples.forEach(example => console.log(` git date ${example}`)); | ||
@@ -32,22 +32,22 @@ console.log(); | ||
process.exit(1); | ||
}; | ||
} | ||
process.argv.splice(0, 2); | ||
if (process.argv.length === 0) { | ||
if (!process.argv.length) { | ||
exit(); | ||
}; | ||
} | ||
let date = process.argv.join(" "); | ||
let parsedDate = new sugar.Date.create(date); | ||
const date = process.argv.join(" "); | ||
const parsedDate = new sugar.Date.create(date); | ||
if (/Invalid Date/.test(parsedDate)) { | ||
exit(`Could not parse "${date}" into a valid date`); | ||
}; | ||
} | ||
let dateString = moment(parsedDate).format("ddd MMM DD HH:mm:ss YYYY ZZ"); | ||
const dateString = moment(parsedDate).format("ddd MMM DD HH:mm:ss YYYY ZZ"); | ||
let command = `GIT_COMMITTER_DATE="${dateString}" git commit --amend --date="${dateString}" --no-edit`; | ||
const command = `GIT_COMMITTER_DATE="${dateString}" git commit --amend --date="${dateString}" --no-edit`; | ||
exec(command, (err, stdout, stderr) => { | ||
if (err || stderr) exit("Could not modify the date of the previous commit"); | ||
console.log(chalk`\nModified previous commit:\n AUTHOR_DATE {grey ${dateString}}\n COMMITTER_DATE {grey ${dateString}}\n\nCommand executed:\n {grey ${command}}\n`); | ||
console.log(chalk`\nModified previous commit:\n AUTHOR_DATE {grey ${dateString}}\n COMMITTER_DATE {grey ${dateString}}\n\nCommand executed:\n {grey ${command}}\n`); | ||
}); |
{ | ||
"name": "git-date", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "easily change the date of the previous git commit", | ||
@@ -5,0 +5,0 @@ "main": "git-date.js", |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
4910
2