Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function loadConfig(configs) {
let configFileObject = {}
console.log(`reading config file at '${configs.config_file}'`)
if (configs.config_file) {
const file = fs.readFileSync(configs.config_file, 'utf8')
configFileObject = YAML.parse(file)
}
config = Object.assign({}, defaultConfig, configFileObject, configs)
return config
}
jsYaml.loadFront = function (context, name) {
var contents;
if(fs.existsSync(context)) {
contents = fs.readFileSync(context, 'utf8');
if (contents instanceof Error) return contents;
return jsYaml.parse(contents, name);
} else if (Buffer.isBuffer(context)) {
return jsYaml.parse(context.toString(), name);
} else {
return jsYaml.parse(context, name);
}
return false;
};
jsYaml.loadFront = function (context, name) {
var contents;
if(fs.existsSync(context)) {
contents = fs.readFileSync(context, 'utf8');
if (contents instanceof Error) return contents;
return jsYaml.parse(contents, name);
} else if (Buffer.isBuffer(context)) {
return jsYaml.parse(context.toString(), name);
} else {
return jsYaml.parse(context, name);
}
return false;
};
try {
if (action.payload.gistId) {
const { response, error } = yield call(github.request, {
method: 'GET',
path: `gists/${action.payload.gistId}`,
})
if (response) {
const gistFiles = response.files
const snippet = YAML.parse(gistFiles[Object.keys(gistFiles)[0]].content)
const solution = convertSnippetToSolution(snippet)
yield put(gists.importSnippet.success({ solution }))
} else {
throw error
}
} else if (action.payload.gist) {
const snippet = YAML.parse(action.payload.gist)
const solution = convertSnippetToSolution(snippet)
yield put(gists.importSnippet.success({ solution }))
} else {
throw new Error('Either a gistId or gist must be specified')
}
} catch (e) {
yield put(gists.importSnippet.failure(e))
}
}
function* importSnippetSaga(action: ActionType) {
try {
if (action.payload.gistId) {
const { response, error } = yield call(github.request, {
method: 'GET',
path: `gists/${action.payload.gistId}`,
})
if (response) {
const gistFiles = response.files
const snippet = YAML.parse(gistFiles[Object.keys(gistFiles)[0]].content)
const solution = convertSnippetToSolution(snippet)
yield put(gists.importSnippet.success({ solution }))
} else {
throw error
}
} else if (action.payload.gist) {
const snippet = YAML.parse(action.payload.gist)
const solution = convertSnippetToSolution(snippet)
yield put(gists.importSnippet.success({ solution }))
} else {
throw new Error('Either a gistId or gist must be specified')
}
} catch (e) {
yield put(gists.importSnippet.failure(e))
}
}
jsYaml.loadFront = function (context, name) {
var contents;
if(fs.existsSync(context)) {
contents = fs.readFileSync(context, 'utf8');
if (contents instanceof Error) return contents;
return jsYaml.parse(contents, name);
} else if (Buffer.isBuffer(context)) {
return jsYaml.parse(context.toString(), name);
} else {
return jsYaml.parse(context, name);
}
return false;
};