Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function travisTransform (config, travisyml) {
try {
var travis = yaml.safeLoad(travisyml, {
schema: yaml.FAILSAFE_SCHEMA
})
} catch (e) {
// ignore .travis.yml if it can not be parsed
return
}
const onlyBranches = _.get(travis, 'branches.only')
if (!onlyBranches || !Array.isArray(onlyBranches)) return
const greenkeeperRule = onlyBranches.some(function (branch) {
if (_.first(branch) !== '/' || _.last(branch) !== '/') return false
try {
const regex = new RegExp(branch.slice(1, -1))
return regex.test(config.branchPrefix)
} catch (e) {
return false
}
function travisTransform (travisYML) {
try {
var travisJSON = yaml.safeLoad(travisYML, {
schema: yaml.FAILSAFE_SCHEMA
})
} catch (e) {
// ignore .travis.yml if it can not be parsed
return
}
// No versions specified in travis YML
if (!_.get(travisJSON, 'node_js')) return
const nodeVersionFromYaml = getNodeVersionsFromTravisYML(travisYML)
const hasNodeVersion = getNodeVersionIndex(nodeVersionFromYaml.versions, nodeVersion, codeName, true) !== -1
if (!hasNodeVersion) return
const updatedTravisYaml = addNewLowestAndDeprecate({
travisYML,
nodeVersion,
codeName,
newLowestVersion,
function travisTransform (travisYML) {
try {
var travisJSON = yaml.safeLoad(travisYML, {
schema: yaml.FAILSAFE_SCHEMA
})
} catch (e) {
// ignore .travis.yml if it can not be parsed
return
}
// No node versions specified in root level of travis YML
// There may be node versions defined in the matrix or jobs keys, but those can become
// far too complex for us to handle, so we don’t
if (!_.get(travisJSON, 'node_js')) return
const nodeVersionFromYaml = getNodeVersionsFromTravisYML(travisYML)
const hasNodeVersion = getNodeVersionIndex(nodeVersionFromYaml.versions, nodeVersion, codeName) !== -1
if (hasNodeVersion) return
const updatedTravisYaml = addNodeVersionToTravisYML(travisYML, nodeVersion, codeName, nodeVersionFromYaml)
return updatedTravisYaml
const type = path[path.length - 1].toLowerCase();
const packageName = file.getPackageName();
let translations;
if (type === 'json') {
try {
translations = JSON.parse(stripJsonComments(source));
} catch (e) {
file.error({
message: `Parsing Error: ${e.message}\n`
});
return;
}
} else {
try {
translations = YAML.load(source, {
schema: YAML.FAILSAFE_SCHEMA,
onWarning: console.warn.bind(console)
});
} catch (e) {
file.error({
message: `Parsing Error: ${e.message}\n`
});
return;
}
}
let locale = translations._locale || getLocaleFromPath(filePath);
if (!locale) {
file.error({
message: `Cannot find localization for file: ${file} ${(
packageName ? 'in package: ' + packageName : ''
)}. Please change file name or set _locale key in file`
export function load(path: string, tsconfigPath: string) {
let txt;
try {
txt = fs.readFileSync(path).toString();
} catch {
throw new Error(`${path} not found`);
}
let obj;
try {
obj = yaml.safeLoad(txt, { schema: yaml.FAILSAFE_SCHEMA });
} catch {
throw new Error('Invalid YAML');
}
return loadConfig(obj, tsconfigPath);
}
export function load(path: string) {
let txt;
try {
txt = fs.readFileSync(path).toString();
} catch {
throw new Error(`${path} not found`);
}
let obj;
try {
obj = yaml.safeLoad(txt, { schema: yaml.FAILSAFE_SCHEMA });
} catch {
throw new Error('Invalid YAML');
}
return loadConfig(obj);
}
toYaml = obj => yaml.safeDump(JSON.parse(JSON.stringify(obj)), {schema: yaml.FAILSAFE_SCHEMA}),
const loadYaml = (slug: string): any => {
return YAML.load(fs.readFileSync(slug, "utf8"), {
schema: YAML.FAILSAFE_SCHEMA
});
};
export const readConfigsFromFile = (
configFilePath: string
): UserSuppliedConfigs => {
try {
return filterOptions(yaml.safeLoad(
fs.readFileSync(configFilePath, 'utf8'),
{schema: yaml.FAILSAFE_SCHEMA},
));
} catch (err) {
throw new Error(`${ERROR_CANNOT_PARSE_CONFIG_FILE.description}: ${err.message}`);
}
};
const loadYaml = (slug) => {
return YAML.load(fs.readFileSync(slug, "utf8"), {
schema: YAML.FAILSAFE_SCHEMA
});
};
exports.loadRegexes = (slug) => {