Comparing version 1.22.1 to 1.23.0
{ | ||
"name": "ggit", | ||
"description": "Local promise-returning git command wrappers", | ||
"version": "1.22.1", | ||
"version": "1.23.0", | ||
"author": "Gleb Bahmutov <gleb.bahmutov@gmail.com>", | ||
@@ -60,3 +60,3 @@ "bin": { | ||
"git-issues": "1.3.1", | ||
"github-post-release": "1.7.1", | ||
"github-post-release": "1.12.1", | ||
"grunt": "0.4.5", | ||
@@ -81,3 +81,3 @@ "grunt-bump": "0.8.0", | ||
"semantic-release": "6.3.6", | ||
"simple-commit-message": "3.1.0", | ||
"simple-commit-message": "3.2.0", | ||
"sinon": "2.3.8", | ||
@@ -84,0 +84,0 @@ "snap-shot": "2.17.0", |
@@ -33,3 +33,3 @@ # ggit | ||
# get last commit id in the current folder, save into json file | ||
ggit last -f build.json | ||
ggit-last -f build.json | ||
@@ -36,0 +36,0 @@ ## API |
@@ -8,20 +8,30 @@ 'use strict' | ||
function save (filename, data) { | ||
var write = require('fs').writeFileSync | ||
var contents = JSON.stringify(data, null, 2) + '\n' | ||
write(filename, contents, 'utf8') | ||
} | ||
function saveBuildFile (filename, id) { | ||
var exists = require('fs').existsSync | ||
var read = require('fs').readFileSync | ||
var short = id.substr(0, 7) | ||
var currentTime = new Date() | ||
var data = { | ||
id: id, | ||
short: short, | ||
savedAt: currentTime.toISOString() | ||
} | ||
if (exists('./package.json')) { | ||
var pkg = JSON.parse(read('./package.json', 'utf8')) | ||
data.version = pkg.version | ||
} | ||
save(filename, data) | ||
console.log('saved last commit %s (short %s) in file %s', id, short, filename) | ||
} | ||
function saveIntoFile (options, id) { | ||
if (check.unemptyString(options.file)) { | ||
var write = require('fs').writeFileSync | ||
var short = id.substr(0, 7) | ||
var currentTime = new Date() | ||
var data = { | ||
id: id, | ||
short: short, | ||
savedAt: currentTime.toISOString() | ||
} | ||
var contents = JSON.stringify(data, null, 2) + '\n' | ||
write(options.file, contents, 'utf8') | ||
console.log( | ||
'saved last commit %s (short %s) in file %s', | ||
id, | ||
short, | ||
options.file | ||
) | ||
saveBuildFile(options.file, id) | ||
} | ||
@@ -28,0 +38,0 @@ console.log('last commit:', id) |
58732
1391
13