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");
});
function getTypoMapsPromise () {
return fsp
.readdir(typoMapsPath)
.then(fileNames => fileNames
.filter(name => /\.yaml$/.test(name))
.map(name => path.join(typoMapsPath, name))
)
.then(filePaths => Promise.all(
filePaths.map(filePath => fsp.readFile(filePath))
))
.then(fileContents => fileContents.map(yaml.safeLoad))
}
jsonfile.readFile(path.join(__dirname, 'schema.json')).then((schema) => {
fs.readdir(path.join(__dirname, 'banks')).then(files => lint(files, schema)).catch((err) => {
logError(err);
process.exit(1);
});
}).catch(logError);
function createService(program, callback){
console.log('Creating auth file...')
var service = {}
var targetPath = program.targetPath || process.cwd()
service.appId = uuid.v4()
service.appName = program.appName || 'unnamed'
service.appSecret = createSecret()
var data = JSON.stringify(service, null, 2)
fs.writeFile(targetPath+'/'+service.appId+'.json', data, 'UTF-8', function (err) {
if (err) console.error(err)
console.log('Create auth file in path '+targetPath)
})
}
function createService(program, callback){
console.log('Creating auth file...')
var service = {}
var targetPath = program.targetPath || process.cwd()
service.appId = uuid.v4()
service.appName = program.appName || 'unnamed'
service.appSecret = createSecret()
var data = JSON.stringify(service, null, 2)
fs.writeFile(targetPath+'/'+service.appId+'.json', data, 'UTF-8', function (err) {
if (err) console.error(err)
console.log('Create auth file in path '+targetPath)
})
}
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);
});
});
};