diff --git a/.gitignore b/.gitignore index 092d025..6fe7a1f 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -\node_modules \ No newline at end of file +\node_modules +config.local.yml \ No newline at end of file diff --git a/README.md b/README.md index 4984a51..b45539a 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,8 @@ Run this commands on project root directory to install Node dependencies. $ npm install ``` +Copy and paste the file config.yml with the name config.local.yml and put the path + ## Built With * [Git](https://git-scm.com/) diff --git a/config.yml b/config.yml new file mode 100644 index 0000000..620ae8c --- /dev/null +++ b/config.yml @@ -0,0 +1 @@ +path: /home/username/Projects/project-name \ No newline at end of file diff --git a/main.js b/main.js index 0fa7bb8..5b7c94a 100644 --- a/main.js +++ b/main.js @@ -1,10 +1,16 @@ +const yml = require('require-yml'); +const path = require('path'); +const fs = require('fs-extra'); const simpleGit = require('simple-git'); const { promisify } = require('util'); -// Local path of the git repository -const repoPath = '/home/username/Projects/project-name'; +let conf = yml(path.join(__dirname, 'config.yml')); +const localConfFile = path.join(__dirname, 'config.local.yml'); +if (fs.existsSync(localConfFile)) + conf = Object.assign({}, conf, yml(localConfFile)); + +const git = simpleGit(conf.path); -const git = simpleGit(repoPath); const gitBranch = promisify(git.branch.bind(git)); const gitPush = promisify(git.push.bind(git)); diff --git a/package-lock.json b/package-lock.json index 2642109..028cd90 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,6 +5,8 @@ "packages": { "": { "dependencies": { + "fs-extra": "^11.1.1", + "require-yml": "^2.0.0", "simple-git": "^3.19.1" } }, @@ -21,6 +23,14 @@ "resolved": "https://registry.npmjs.org/@kwsites/promise-deferred/-/promise-deferred-1.1.1.tgz", "integrity": "sha512-GaHYm+c0O9MjZRu0ongGBRbinu8gVAMd2UZjji6jVmqKtZluZnptXGWhz1E8j8D2HJ3f/yMxKAUC0b+57wncIw==" }, + "node_modules/argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dependencies": { + "sprintf-js": "~1.0.2" + } + }, "node_modules/debug": { "version": "4.3.4", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", @@ -37,11 +47,72 @@ } } }, + "node_modules/esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "bin": { + "esparse": "bin/esparse.js", + "esvalidate": "bin/esvalidate.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/fs-extra": { + "version": "11.1.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.1.1.tgz", + "integrity": "sha512-MGIE4HOvQCeUCzmlHs0vXpih4ysz4wg9qiSAu6cd42lVwPbTM1TjV7RusoyQqMmk/95gdQZX72u+YW+c3eEpFQ==", + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=14.14" + } + }, + "node_modules/graceful-fs": { + "version": "4.2.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==" + }, + "node_modules/js-yaml": { + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "dependencies": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/jsonfile": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", + "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", + "dependencies": { + "universalify": "^2.0.0" + }, + "optionalDependencies": { + "graceful-fs": "^4.1.6" + } + }, "node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, + "node_modules/require-yml": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/require-yml/-/require-yml-2.0.0.tgz", + "integrity": "sha512-GtMiHsSJcYlV6blHjz8b/cziazShC9DhGu77CmwbIu8I/Y8F9Yb8XIsQqEmh03KOtS/GTviLYwfvjxjm2NYU+Q==", + "dependencies": { + "js-yaml": "~3.13.0" + } + }, "node_modules/simple-git": { "version": "3.19.1", "resolved": "https://registry.npmjs.org/simple-git/-/simple-git-3.19.1.tgz", @@ -55,6 +126,19 @@ "type": "github", "url": "https://github.com/steveukx/git-js?sponsor=1" } + }, + "node_modules/sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==" + }, + "node_modules/universalify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", + "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", + "engines": { + "node": ">= 10.0.0" + } } } } diff --git a/package.json b/package.json index fdb8687..4d620ea 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,7 @@ { "dependencies": { + "fs-extra": "^11.1.1", + "require-yml": "^2.0.0", "simple-git": "^3.19.1" } }