mirror of
https://github.com/OBKoro1/autoCommit.git
synced 2024-12-22 17:19:19 +08:00
autoCommit
This commit is contained in:
parent
094d8a4484
commit
1fd11ec05a
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
node_modules
|
17
.vscode/launch.json
vendored
Normal file
17
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
// 使用 IntelliSense 了解相关属性。
|
||||
// 悬停以查看现有属性的描述。
|
||||
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "启动程序",
|
||||
"skipFiles": [
|
||||
"<node_internals>/**"
|
||||
],
|
||||
"program": "${workspaceFolder}/src/index.js"
|
||||
}
|
||||
]
|
||||
}
|
22
package.json
Normal file
22
package.json
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "autocommit",
|
||||
"version": "1.0.0",
|
||||
"description": "自动commit工具",
|
||||
"main": "src/index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/OBKoro1/autoCommit.git"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"bugs": {
|
||||
"url": "https://github.com/OBKoro1/autoCommit/issues"
|
||||
},
|
||||
"homepage": "https://github.com/OBKoro1/autoCommit#readme",
|
||||
"dependencies": {
|
||||
"moment": "^2.24.0"
|
||||
}
|
||||
}
|
47
src/index.js
Normal file
47
src/index.js
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Author : OBKoro1
|
||||
* Date : 2019-12-19 20:23:57
|
||||
* LastEditors : OBKoro1
|
||||
* LastEditTime : 2019-12-20 11:11:29
|
||||
* FilePath : /autoCommit/index.js
|
||||
* Description : 自动commit
|
||||
* https://github.com/OBKoro1
|
||||
*/
|
||||
|
||||
const { execSync } = require('child_process');
|
||||
const moment = require('moment');
|
||||
const fs = require('fs');
|
||||
|
||||
class autoCommit {
|
||||
constructor() {
|
||||
this.init();
|
||||
}
|
||||
|
||||
init() {
|
||||
const time = moment().format('DD/MM/YYYY HH:MM:ss');
|
||||
fs.writeFileSync('./test.md', time, 'utf-8');
|
||||
this.commit()
|
||||
}
|
||||
commit() {
|
||||
this.myExecSync(`git add . && git commit -m 'autoCommit' && git pull && git push`)
|
||||
}
|
||||
|
||||
myExecSync(cmd) {
|
||||
// 除了该方法直到子进程完全关闭后才返回 执行完毕 返回
|
||||
try {
|
||||
const res = execSync(cmd, {
|
||||
encoding: 'utf8',
|
||||
timeout: 0,
|
||||
maxBuffer: 200 * 1024,
|
||||
killSignal: 'SIGTERM',
|
||||
cwd: undefined,
|
||||
env: undefined
|
||||
});
|
||||
return res;
|
||||
} catch (err) {
|
||||
console.log(`执行命令出错:${cmd}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
new autoCommit();
|
8
yarn.lock
Normal file
8
yarn.lock
Normal file
@ -0,0 +1,8 @@
|
||||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
moment@^2.24.0:
|
||||
version "2.24.0"
|
||||
resolved "https://registry.yarnpkg.com/moment/-/moment-2.24.0.tgz#0d055d53f5052aa653c9f6eb68bb5d12bf5c2b5b"
|
||||
integrity sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg==
|
Loading…
Reference in New Issue
Block a user