Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
exports.editMessage = co.wrap(function *(repo, initialContents) {
const messagePath = path.join(repo.path(), "COMMIT_EDITMSG");
yield fs.writeFile(messagePath, initialContents);
const editorCommand = yield exports.getEditorCommand(repo);
// TODO: if we ever need this to work on Windows, we'll need to do
// something else. The `ChildProcess.exec` method doesn't provide for a
// way to auto-redirect stdio or I'd use it.
yield ChildProcess.spawn("/bin/sh",
["-c", `${editorCommand} '${messagePath}'`], {
stdio: "inherit",
});
return yield fs.readFile(messagePath, "utf8");
});
exports.editMessage = co.wrap(function *(repo, initialContents) {
const messagePath = path.join(repo.path(), "COMMIT_EDITMSG");
yield fs.writeFile(messagePath, initialContents);
const editorCommand = yield exports.getEditorCommand(repo);
// TODO: if we ever need this to work on Windows, we'll need to do
// something else. The `ChildProcess.exec` method doesn't provide for a
// way to auto-redirect stdio or I'd use it.
yield ChildProcess.spawn("/bin/sh",
["-c", `${editorCommand} '${messagePath}'`], {
stdio: "inherit",
});
return yield fs.readFile(messagePath, "utf8");
});
return Promise.all(promises).then(function(yamlSchemes) {
yamlSchemes = yamlSchemes.map(yamlScheme => yaml.load(yamlScheme));
return fs
.readFile(path.join(__dirname, './schemesPreview.ejs'), 'utf-8')
.then(function(templ) {
const preview = ejs.render(templ, {
schemes: yamlSchemes
});
return fs.writeFile(path.join(__dirname, '../dist/index.html'), preview);
});
});
})
function readManifest() {
return fsp
.readFile(path.resolve(rootPath, 'dist/app/webpack-assets.json'))
.then(content => JSON.parse(content))
}
function buildTemplate() {
return fsp
.readFile(path.join(rootPath, 'index.ejs'))
.then(templateContent => ejs.compile(templateContent.toString()))
}
return new Promise((resolve, reject) => {
return fs.readFile(file, 'utf-8').then(data => {
svgson(data, applyExtras(fileName), resolve);
});
});
};
return new Promise((resolve,reject) => {
return fs.readFile(filePath, 'utf8').then(data => {
process.stdout.cursorTo(0);
process.stdout.clearLine();
process.stdout.write(file);
svgson(data, applyExtras(fileName), resolve);
});
});
};
exports.readFile = co.wrap(function *(gitDir, name) {
assert.isString(gitDir);
assert.isString(name);
const filePath = path.join(gitDir, SEQUENCER_DIR, name);
try {
return yield fs.readFile(filePath, "utf8");
}
catch (e) {
return null;
}
});
async function checkFile() {
const file = path.join(config.get('dataDirectory'), 'testfile');
const key = shortid.generate();
await fs.writeFile(file, `testfile.${key}`);
const res = await fs.readFile(file, 'utf8');
await fs.unlink(file);
const stillExists = await fs.exists(file);
if (res === `testfile.${key}` && !stillExists) {
return;
}
throw new Error('Unknown reason');
}