Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function filesToCommit(path) {
const simpleGit = new SimpleGit(path);
const gitDiff = promisify(simpleGit.diff, simpleGit);
return gitDiff(['--name-status', '--cached'])
.then(output => {
return output
.split('\n')
.filter(line => line.trim().length > 0) // Ignore blank lines
.map(line => line.trim().split('\t'))
.map(parts => {
const status = parts[0];
// If a file's been edited, it will only have 2 elements. If it's been renamed it will have
// 3 elements. But in both cases, the last element is the current name of the file.
const name = parts[parts.length - 1];
return { status, name };
})
.filter(file => file.status !== 'D'); // Ignore deleted files
async function buildGallery(comparisons) {
const simpleGit = new SimpleGit();
const asyncBranch = promisify(simpleGit.branch, simpleGit);
const branch = await asyncBranch();
const template = Handlebars.compile(
await readFileAsync(
path.resolve('./utilities/templates/visual_regression_gallery.handlebars'),
'utf8'
),
{ knownHelpersOnly: true }
);
const html = template({
date: moment().format('MMMM Do YYYY, h:mm:ss a'),
branch: branch.current,
hiddenThreshold: 0,
warningThreshold: 0.03,
export default function gitCli (workingDir?: string) {
let simpleGitInstance = simpleGit(workingDir)
simpleGitInstance.silent(global.ernLogLevel !== 'trace')
return Prom.promisifyAll(simpleGitInstance)
}
return new Promise((resolve, reject) => {
git(workPath).env({
...process.env,
GIT_SSH_COMMAND
})
.pull((err, update) => {
if (err) {
reject(err)
return
}
if (update && update.summary.changes) {
resolve({
code: 1,
type: 'pull',
change: true
})
} else {
resolve({
export default function gitInfo() {
const git = simpleGit(gitDir);
return new Promise((resolve, reject) => {
git.log((err, log) => {
if (err) return reject(err);
resolve({
number: log.total,
sha: log.latest.hash,
});
});
});
}
function GitApi(directory) {
var git = simpleGit(directory);
return {
/**
* @description Initializes a git repository.
* @param {function} callback - A callback to be run on complete.
*/
init: function(callback) {
git.init(false, callback);
},
/**
* @description Pulls in from a remote branch.
* @param {string} remote - The remote location of the git repo.
* @param {string} branch - The branch to be pulled from, typically master.
* @param {function} callback - A callback to be run on complete.
*/
pull: function(remote, branch, callback) {
loadGit() {
this.git = SimpleGit(this.path);
this.git.silent(true);
Promise.promisifyAll(this.git);
this.git.runAsync = Promise.promisify(this.git._run);
}
import fs from 'fs';
import simpleGit from 'simple-git';
import { gitPath, dummyFilePath } from 'config';
const git = simpleGit(gitPath);
export function dummyCommit(day) {
return new Promise((resolve, reject) => {
fs.writeFile(dummyFilePath, Math.random().toString(), (err) => {
if (err) {
reject(err);
} else {
git.add(dummyFilePath, () => {
git.commit('Dummy', dummyFilePath, {'--date': day.time.format()}, resolve);
});
}
});
});
}
this.prompt(prompts, res => {
this.opts.projectName = slug(res.projectName);
const dir = path.join('.', this.opts.projectName);
if (!pathExists.sync(dir)) this.destinationRoot(dir);
else this.env.error(`the directory '${this.opts.projectName}' already exists!`);
this.git = simpleGit(this.destinationRoot());
this.opts.description = res.description;
this.opts.githubName = res.githubName;
this.opts.buildDir = slug(res.buildDir);
done();
});
}