added CI tests
This commit is contained in:
parent
db27753aac
commit
e0daf85e34
4
dist/smartgit.add.d.ts
vendored
4
dist/smartgit.add.d.ts
vendored
@ -1 +1,3 @@
|
||||
export declare let add: (dirPathArg: string) => any;
|
||||
export declare let add: {
|
||||
addAll: (dirPathArg: string) => any;
|
||||
};
|
||||
|
11
dist/smartgit.add.js
vendored
11
dist/smartgit.add.js
vendored
@ -1,17 +1,20 @@
|
||||
"use strict";
|
||||
var plugins = require("./smartgit.plugins");
|
||||
var helpers = require("./smartgit.helpers");
|
||||
exports.add = function (dirPathArg) {
|
||||
var addAll = function (dirPathArg) {
|
||||
var done = plugins.Q.defer();
|
||||
if (!helpers.isGitDirectory(dirPathArg)) {
|
||||
plugins.beautylog.error("smartgit.add expects a valif git directory!");
|
||||
plugins.beautylog.error("smartgit.add expects a valid git directory!");
|
||||
done.reject();
|
||||
return done.promise;
|
||||
}
|
||||
;
|
||||
// if everything is ok proceed
|
||||
plugins.shelljs.exec("");
|
||||
plugins.shelljs.exec("(cd " + dirPathArg + " && git add -A && git status)");
|
||||
done.resolve(dirPathArg);
|
||||
return done.promise;
|
||||
};
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRnaXQuYWRkLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRnaXQuYWRkLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxJQUFZLE9BQU8sV0FBTSxvQkFBb0IsQ0FBQyxDQUFBO0FBQzlDLElBQVksT0FBTyxXQUFNLG9CQUFvQixDQUFDLENBQUE7QUFFbkMsV0FBRyxHQUFHLFVBQUMsVUFBaUI7SUFDL0IsSUFBSSxJQUFJLEdBQUcsT0FBTyxDQUFDLENBQUMsQ0FBQyxLQUFLLEVBQUUsQ0FBQztJQUM3QixFQUFFLENBQUEsQ0FBQyxDQUFDLE9BQU8sQ0FBQyxjQUFjLENBQUMsVUFBV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QUFFLENBQUM7UUFDZCxNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQztJQUN4QixDQUFDO0lBQUEsQ0FBQztJQUNGLDhCQUE4QjtJQUM5QixPQUFPLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxTQUFPLFVBQVUsa0NBQStCLENBQUMsQ0FBQztJQUN2RSxJQUFJLENBQUMsT0FBTyxDQUFDLFVBQVUsQ0FBQyxDQUFDO0lBQ3pCLE1BQU0sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDO0FBQ3hCLENBQUMsQ0FBQztBQUVTLFdBQUcsR0FBRztJQUNiLE1BQU0sRUFBRSxNQUFNO0NBQ2pCLENBQUEifQ==
|
4
dist/smartgit.commit.js
vendored
4
dist/smartgit.commit.js
vendored
@ -10,8 +10,8 @@ exports.commit = function (dirPathArg, commitMessage) {
|
||||
}
|
||||
;
|
||||
// if everything is all right proceed
|
||||
plugins.shelljs.exec("git commit -m \"" + commitMessage + "\"");
|
||||
plugins.shelljs.exec("(cd " + dirPathArg + " && git commit -m \"" + commitMessage + "\")");
|
||||
done.resolve();
|
||||
return done.promise;
|
||||
};
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRnaXQuY29tbWl0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRnaXQuY29tbWl0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxJQUFZLE9BQU8sV0FBTSxvQkFBb0IsQ0FBQyxDQUFBO0FBQzlDLElBQVksT0FBTyxXQUFNLG9CQUFvQixDQUFDLENBQUE7QUFFbkMsY0FBTSxHQUFHLFVBQUMsVUFBaUIsRUFBQyxhQUFvQjtJQUN2RCxJQUFJLElBQUksR0FBRyxPQUFPLENBQUMsQ0FBQyxDQUFDLEtBQUssRUFBRSxDQUFDO0lBQzdCLEVBQUUsQ0FBQSxDQUFDLENBQUM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TUFBTSxFQUFFLENBQUM7UUFDZCxNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQztJQUN4QixDQUFDO0lBQUEsQ0FBQztJQUNGLHFDQUFxQztJQUNyQyxPQUFPLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxTQUFPLFVBQVUsNEJBQXNCLGFBQWEsUUFBSSxDQUFDLENBQUM7SUFDL0UsSUFBSSxDQUFDLE9BQU8sRUFBRSxDQUFDO0lBQ2YsTUFBTSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUM7QUFDeEIsQ0FBQyxDQUFDIn0=
|
9
dist/smartgit.helpers.js
vendored
9
dist/smartgit.helpers.js
vendored
@ -1,6 +1,11 @@
|
||||
"use strict";
|
||||
var plugins = require("./smartgit.plugins");
|
||||
exports.isGitDirectory = function (dirPathArg) {
|
||||
return plugins.smartfile.fs.isDirectory(plugins.path.join(dirPathArg, ".git"));
|
||||
try {
|
||||
return plugins.smartfile.fs.isDirectory(plugins.path.join(dirPathArg, ".git"));
|
||||
}
|
||||
catch (err) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRnaXQuaGVscGVycy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0Z2l0LmhlbHBlcnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLElBQVksT0FBTyxXQUFNLG9CQUFvQixDQUFDLENBQUE7QUFFbkMsc0JBQWMsR0FBRyxVQUFDLFVBQVU7SUFDbkMsTUFBTSxDQUFDLE9BQU8sQ0FBQyxTQUFTLENBQUMsRUFBRSxDQUFDLFdBQVcsQ0FDbkMsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsVUFBVSxFQUFDLE1BQU0sQ0FBQyxDQUN2QyxDQUFDO0FBQ04sQ0FBQyxDQUFBIn0=
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRnaXQuaGVscGVycy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0Z2l0LmhlbHBlcnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLElBQVksT0FBTyxXQUFNLG9CQUFvQixDQUFDLENBQUE7QUFFbkMsc0JBQWMsR0FBRyxVQUFDLFVBQVU7SUFDbkMsSUFBSSxDQUFDO1FBQ0QsTUFBTSxDQUFDLE9BQU8sQ0FBQyxTQUFTLENBQUMsRUFBRSxDQUFDLFdBQVcsQ0FDbkMsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsVUFBVSxFQUFDLE1BQU0sQ0FBQyxDQUN2QyxDQUFDO0lBQ04sQ0FDQTtJQUFBLEtBQUssQ0FBQSxDQUFDLEdBQUcsQ0FBQyxDQUFBLENBQUM7UUFDUCxNQUFNLENBQUMsS0FBSyxDQUFDO0lBQ2pCLENBQUM7QUFDTCxDQUFDLENBQUEifQ==
|
@ -5,7 +5,7 @@
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"scripts": {
|
||||
"cleanTest": "rm -rf test/temp && rm -rf test/temp2",
|
||||
"cleanTest": "rm -rf test/temp*",
|
||||
"test": "(npm run cleanTest && npmts)",
|
||||
"install": "node dist/postinstall.js"
|
||||
},
|
||||
|
44
test/test.js
44
test/test.js
@ -1,15 +1,23 @@
|
||||
"use strict";
|
||||
require("typings-test");
|
||||
var shelljs = require("shelljs");
|
||||
var path = require("path");
|
||||
require("should");
|
||||
var smartgit = require("../dist/index");
|
||||
var paths = {
|
||||
temp: path.resolve("./test/temp/"),
|
||||
temp2: path.resolve("./test/temp2/"),
|
||||
temp3: path.resolve("./test/temp3"),
|
||||
temp4: path.resolve("./test/temp4"),
|
||||
noGit: path.resolve("./test/")
|
||||
};
|
||||
describe("smartgit", function () {
|
||||
describe(".clone", function () {
|
||||
it("should clone a repository using ssh and sshkey", function (done) {
|
||||
this.timeout(20000);
|
||||
smartgit.clone({
|
||||
from: "git@gitlab.com:sandboxzone/sandbox-testrepo.git",
|
||||
to: path.resolve("./test/temp/")
|
||||
to: paths.temp
|
||||
}).then(function () {
|
||||
done();
|
||||
});
|
||||
@ -18,17 +26,45 @@ describe("smartgit", function () {
|
||||
this.timeout(20000);
|
||||
smartgit.clone({
|
||||
from: "https://gitlab.com/sandboxzone/sandbox-testrepo.git",
|
||||
to: path.resolve("./test/temp2/")
|
||||
to: paths.temp2
|
||||
}).then(function () {
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
describe(".check", function () {
|
||||
describe(".add", function () {
|
||||
it("should error for noGit", function () {
|
||||
smartgit.add.addAll(paths.noGit);
|
||||
});
|
||||
it("should add a file to an existing repository", function () {
|
||||
shelljs.exec("(cd " + paths.temp + " && cp ../test.js .)");
|
||||
smartgit.add.addAll(paths.temp);
|
||||
});
|
||||
});
|
||||
describe("commit", function () {
|
||||
it("should error for noGit", function () {
|
||||
smartgit.commit(paths.noGit, "some commit message");
|
||||
});
|
||||
it("should commit a new file to an existing repository", function () {
|
||||
smartgit.commit(paths.temp, "added a new file");
|
||||
});
|
||||
});
|
||||
describe("init", function () {
|
||||
it("should error for noGit", function () {
|
||||
smartgit.init(paths.noGit);
|
||||
});
|
||||
it("should init a new git", function () {
|
||||
smartgit.init(paths.temp3);
|
||||
});
|
||||
});
|
||||
describe("pull", function () {
|
||||
this.timeout(10000);
|
||||
it("should error for noGit", function () {
|
||||
smartgit.pull(paths.noGit);
|
||||
});
|
||||
it("should pull from origin", function () {
|
||||
smartgit.pull(paths.temp);
|
||||
});
|
||||
});
|
||||
});
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZX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BQyxDQUFDIn0=
|
45
test/test.ts
45
test/test.ts
@ -1,9 +1,17 @@
|
||||
import "typings-test";
|
||||
import beautylog = require("beautylog");
|
||||
let shelljs = require("shelljs");
|
||||
import path = require("path");
|
||||
import "should"
|
||||
|
||||
import smartgit = require("../dist/index");
|
||||
let paths = {
|
||||
temp: path.resolve("./test/temp/"),
|
||||
temp2: path.resolve("./test/temp2/"),
|
||||
temp3: path.resolve("./test/temp3"),
|
||||
temp4: path.resolve("./test/temp4"),
|
||||
noGit: path.resolve("./test/")
|
||||
}
|
||||
|
||||
describe("smartgit",function(){
|
||||
describe(".clone",function(){
|
||||
@ -11,7 +19,7 @@ describe("smartgit",function(){
|
||||
this.timeout(20000);
|
||||
smartgit.clone({
|
||||
from:"git@gitlab.com:sandboxzone/sandbox-testrepo.git",
|
||||
to:path.resolve("./test/temp/")
|
||||
to:paths.temp
|
||||
}).then(function(){
|
||||
done();
|
||||
});
|
||||
@ -20,19 +28,44 @@ describe("smartgit",function(){
|
||||
this.timeout(20000);
|
||||
smartgit.clone({
|
||||
from:"https://gitlab.com/sandboxzone/sandbox-testrepo.git",
|
||||
to:path.resolve("./test/temp2/")
|
||||
to:paths.temp2
|
||||
}).then(function(){
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
describe(".check",function(){
|
||||
|
||||
describe(".add",function(){
|
||||
it("should error for noGit",function(){
|
||||
smartgit.add.addAll(paths.noGit);
|
||||
})
|
||||
it("should add a file to an existing repository",function(){
|
||||
shelljs.exec(`(cd ${paths.temp} && cp ../test.js .)`)
|
||||
smartgit.add.addAll(paths.temp);
|
||||
})
|
||||
});
|
||||
describe("commit",function(){
|
||||
|
||||
it("should error for noGit",function(){
|
||||
smartgit.commit(paths.noGit,"some commit message");
|
||||
})
|
||||
it("should commit a new file to an existing repository",function(){
|
||||
smartgit.commit(paths.temp,"added a new file");
|
||||
})
|
||||
});
|
||||
describe("init",function(){
|
||||
|
||||
it("should error for noGit",function(){
|
||||
smartgit.init(paths.noGit);
|
||||
});
|
||||
it("should init a new git",function(){
|
||||
smartgit.init(paths.temp3);
|
||||
})
|
||||
});
|
||||
describe("pull",function(){
|
||||
this.timeout(10000);
|
||||
it("should error for noGit",function(){
|
||||
smartgit.pull(paths.noGit);
|
||||
});
|
||||
it("should pull from origin",function(){
|
||||
smartgit.pull(paths.temp);
|
||||
})
|
||||
});
|
||||
});
|
@ -1,15 +1,19 @@
|
||||
import * as plugins from "./smartgit.plugins";
|
||||
import * as helpers from "./smartgit.helpers";
|
||||
|
||||
export let add = (dirPathArg:string) => {
|
||||
let addAll = (dirPathArg:string) => {
|
||||
let done = plugins.Q.defer();
|
||||
if(!helpers.isGitDirectory(dirPathArg)){
|
||||
plugins.beautylog.error("smartgit.add expects a valif git directory!");
|
||||
plugins.beautylog.error("smartgit.add expects a valid git directory!");
|
||||
done.reject();
|
||||
return done.promise;
|
||||
};
|
||||
// if everything is ok proceed
|
||||
plugins.shelljs.exec("");
|
||||
plugins.shelljs.exec(`(cd ${dirPathArg} && git add -A && git status)`);
|
||||
done.resolve(dirPathArg);
|
||||
return done.promise;
|
||||
};
|
||||
|
||||
export let add = {
|
||||
addAll: addAll
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ export let commit = (dirPathArg:string,commitMessage:string) => {
|
||||
return done.promise;
|
||||
};
|
||||
// if everything is all right proceed
|
||||
plugins.shelljs.exec(`git commit -m "${commitMessage}"`);
|
||||
plugins.shelljs.exec(`(cd ${dirPathArg} && git commit -m "${commitMessage}")`);
|
||||
done.resolve();
|
||||
return done.promise;
|
||||
};
|
@ -1,7 +1,12 @@
|
||||
import * as plugins from "./smartgit.plugins";
|
||||
|
||||
export let isGitDirectory = (dirPathArg):boolean => {
|
||||
return plugins.smartfile.fs.isDirectory(
|
||||
plugins.path.join(dirPathArg,".git")
|
||||
);
|
||||
try {
|
||||
return plugins.smartfile.fs.isDirectory(
|
||||
plugins.path.join(dirPathArg,".git")
|
||||
);
|
||||
}
|
||||
catch(err){
|
||||
return false;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user