Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
assert.lengthOf(x, 5);
b64 = baseN.create({
length: 2
});
x = b64.encode(5);
assert.isString(x);
assert.lengthOf(x, 2);
// can also fix length by giving a max integer value allowed.
// this should be two characters. (64^2)
b64 = baseN.create({
max: 4095
});
x = b64.encode(5);
assert.isString(x);
assert.lengthOf(x, 2);
});
function* checkUpdate(repo, notesRepo, oldSha, newSha, handled) {
assert.instanceOf(repo, NodeGit.Repository);
assert.instanceOf(notesRepo, NodeGit.Repository);
assert.isString(oldSha);
assert.isString(newSha);
assert.isObject(handled);
// deleting is OK
if (newSha === "0000000000000000000000000000000000000000") {
return true;
}
const newAnnotated = yield GitUtil.resolveCommitish(repo, newSha);
if (newAnnotated === null) {
// No such commit exists, error
return false;
}
const newCommit = yield repo.getCommit(newAnnotated.id());
const addSubmodule = co.wrap(function *(repo, url, path, sha) {
assert.instanceOf(repo, NodeGit.Repository);
assert.isString(url);
assert.isString(path);
assert.isString(sha);
const submodule = yield NodeGit.Submodule.addSetup(repo, url, path, 1);
const subRepo = yield submodule.open();
const origin = yield subRepo.getRemote("origin");
yield origin.connect(NodeGit.Enums.DIRECTION.FETCH,
new NodeGit.RemoteCallbacks(),
function () {});
yield subRepo.fetch("origin", {});
subRepo.setHeadDetached(sha);
const commit = yield subRepo.getCommit(sha);
yield NodeGit.Reset.reset(subRepo, commit, NodeGit.Reset.TYPE.HARD);
yield submodule.addFinalize();
return submodule;
});
hashes: { it: 'should be an object with strings input, output, params ', fn: (val) => {
assert.isOk(val.hasOwnProperty('input'))
assert.isString(val['input'])
assert.isOk(val.hasOwnProperty('output'))
assert.isString(val['output'])
assert.isOk(val.hasOwnProperty('params'))
assert.isString(val['params'])
} },
name: { it: 'should be "Unnamed Task"', fn: (val) => assert.equal('Unnamed Task', val) },
export function assertFormatMD5(value:string, msg?:string):void {
assert.isString(value, msg);
assert.match(value, md5RegExp, msg);
}
exports.destitch = co.wrap(function *(repo,
commitish,
metaRemoteName,
targetRefName) {
assert.instanceOf(repo, NodeGit.Repository);
assert.isString(commitish);
assert.isString(metaRemoteName);
if (null !== targetRefName) {
assert.isString(targetRefName);
}
const annotated = yield GitUtil.resolveCommitish(repo, commitish);
if (null === annotated) {
throw new UserError(`\
Could not resolve '${commitish}' to a commit.`);
}
const commit = yield repo.getCommit(annotated.id());
if (!(yield GitUtil.isValidRemoteName(repo, metaRemoteName))) {
throw new UserError(`Invalid remote name: '${metaRemoteName}'.`);
}
const remote = yield NodeGit.Remote.lookup(repo, metaRemoteName);
const baseUrl = remote.url();
exports.readNote = co.wrap(function *(repo, notesRef, oid) {
assert.instanceOf(repo, NodeGit.Repository);
assert.isString(notesRef);
assert(typeof(oid) === "string" || oid instanceof NodeGit.Oid);
try {
return yield NodeGit.Note.read(repo, notesRef, oid);
}
catch (e) {
return null;
}
});
it ('should send the email with json transport', async function () {
const r = await sendEmail('test', { email: 'kartikayg@gmail.com' }, { name: 'Kartik' }, undefined, {
jsonTransport: true,
logger: true
});
assert.isString(r.messageId);
});
exports.parseRepoShorthand = function (shorthand) {
assert.isString(shorthand);
shorthand = shorthand.trim();
const rawResult = exports.parseRepoShorthandRaw(shorthand);
assert.equal(0,
Object.keys(rawResult.openSubmodules),
"open submodules not supported in single-repo shorthand");
const baseAST = getBaseRepo(rawResult.type, rawResult.typeData);
assert.isNotNull(baseAST, `invalid base repo type ${rawResult.type}`);
const resultArgs = prepareASTArguments(baseAST, rawResult);
const fin = baseAST.copy(resultArgs);
return fin;
};
.then((parts) => {
assert.lengthOf(parts.files, 1);
const file = parts.files[0];
assert.include(file, { fieldname: 'someBinaryField' });
assert.isString(file.filename);
});
});