hexo-git-backup
Advanced tools
Comparing version 0.0.2 to 0.0.3
51
index.js
var util = require('util'); | ||
var run = require('execSync').run; | ||
process.env.DEBUG = '';//"hexo-backup" | ||
var log = require('debug')("hexo-backup"); | ||
var backupOptions = { | ||
alias: 'b', // hexo backup/b | ||
alias: 'b', // hexo backup or hexo b, either is fun. | ||
options: [{ | ||
name: '-i,--init', | ||
desc: 'git init git remote branch' | ||
desc: 'git init and git remote branch' | ||
}] | ||
@@ -15,3 +13,3 @@ } | ||
// hexo is a global variable | ||
hexo.extend.console.register("backup", "backup your hexo blog into github, your themes not included", backupOptions, backup); | ||
hexo.extend.console.register("backup", "backup your hexo bdebug into github, your themes not included", backupOptions, backup); | ||
@@ -25,9 +23,6 @@ | ||
function backup(args, cb) { | ||
function backup(args, callback) { | ||
if (!hexo.config.backup) { | ||
throw new Error("please add backup info into _config.yml, branch & repo ..."); | ||
throw new Error("please add backup info into _config.yml"); | ||
} | ||
log(hexo.base_dir) | ||
process.chdir(hexo.base_dir) | ||
@@ -42,44 +37,18 @@ | ||
if (args.init || args.i) { | ||
log("git init"); | ||
run("git init .") | ||
run("git init.") | ||
run(util.format("git checkout %s",branch)); | ||
run(util.format("git remote add backup %s",repository)); | ||
run("git add --all") | ||
return; | ||
} | ||
// backup | ||
log("backup"); | ||
run("git add --all") | ||
// start backup | ||
run(util.format('git commit -a -m "backup at %s"', getnow())) | ||
run(util.format("git push backup %s",branch)) | ||
cb(); | ||
callback(); | ||
} | ||
function getnow() { | ||
var ret = "%s-%s-%s %s:%s:%s" | ||
var d = new Date() | ||
var year = pad(d.getFullYear(), 4), | ||
mon = pad(d.getMonth() + 1, 2), | ||
day = pad(d.getDate(), 2), | ||
hour = pad(d.getHours(), 2), | ||
min = pad(d.getMinutes(), 2), | ||
sec = pad(d.getSeconds(), 2); | ||
return util.format(ret, year, mon, day, hour, min, sec); | ||
return d.toLocaleString(); | ||
} | ||
function pad(original, len, char) { | ||
if (arguments.length < 2) | ||
throw new Error("must specify original_string & expect_length") | ||
char = char || '0'; | ||
var ret = original.toString() | ||
while (ret.length < len) { | ||
ret = char + ret | ||
} | ||
return ret; | ||
} |
{ | ||
"name": "hexo-git-backup", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "hexo backup plugin for Hexo,backup to github", | ||
@@ -26,5 +26,4 @@ "main": "index", | ||
"dependencies": { | ||
"debug": "^2.0.0", | ||
"execSync": "^1.0.2" | ||
} | ||
} |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
1
0
3529
43
- Removeddebug@^2.0.0
- Removeddebug@2.6.9(transitive)
- Removedms@2.0.0(transitive)