Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public insert = async ({ meta, artifacts }: BuildStruct): Promise => {
const build = new Build(meta, artifacts);
const res = await this._pool.query(
'INSERT INTO builds (branch, revision, timestamp, parentRevision, meta, artifacts) VALUES ($1, $2, $3, $4, $5, $6)',
[
build.getMetaValue('branch'),
build.getMetaValue('revision'),
build.meta.timestamp,
build.getMetaValue('parentRevision'),
JSON.stringify(build.meta),
JSON.stringify(build.artifacts)
]
);
if (res.rowCount !== 1) {
throw new Error('Unable to insert build');
}
public insert = ({ meta, artifacts }: BuildStruct): Promise => {
const build = new Build(meta, artifacts);
return new Promise((resolve, reject) => {
this._pool.query(
'INSERT INTO builds (branch, revision, timestamp, parentRevision, meta, artifacts) VALUES (?, ?, ?, ?, ?, ?)',
[
build.getMetaValue('branch'),
build.getMetaValue('revision'),
build.meta.timestamp,
build.getMetaValue('parentRevision'),
JSON.stringify(build.meta),
JSON.stringify(build.artifacts)
],
(err, results): void => {
if (err) {
reject(err);
return;
}
public insert = async ({ meta, artifacts }: BuildStruct): Promise => {
const build = new Build(meta, artifacts);
await this._pool.query(
'INSERT INTO builds (branch, revision, timestamp, parentRevision, meta, artifacts) VALUES (?, ?, ?, ?, ?, ?)',
[
build.getMetaValue('branch'),
build.getMetaValue('revision'),
build.meta.timestamp,
build.getMetaValue('parentRevision'),
JSON.stringify(build.meta),
JSON.stringify(build.artifacts)
]
);
return Promise.resolve(build.getMetaValue('revision'));
};
glob.sync(`${path.join(fixturePath, 'builds')}/*.json`).forEach(async build => {
const buildData = require(build);
await config.queries.build.insert(new Build(buildData.meta, buildData.artifacts));
});
.then(parentBuildData => {
const parentBuild = new Build(parentBuildData.meta, parentBuildData.artifacts);
return {
comparator: new Comparator({
artifactBudgets: artifactConfig.budgets,
artifactFilters: artifactConfig.filters,
builds: [build, parentBuild],
groups: artifactConfig.groups
})
};
})
.then(context => {
): RequestHandler => (req: Request, res: Response): void => {
const { artifacts, meta } = req.body;
const { artifacts: artifactConfig = {} } = config;
const build = new Build(meta, artifacts);
queries.insert(build).then(() =>
queries
.byRevision(build.getMetaValue('parentRevision'))
.then(parentBuildData => {
const parentBuild = new Build(parentBuildData.meta, parentBuildData.artifacts);
return {
comparator: new Comparator({
artifactBudgets: artifactConfig.budgets,
artifactFilters: artifactConfig.filters,
builds: [build, parentBuild],
groups: artifactConfig.groups
})
};
})
.then(context => {
return onInserted(context.comparator).then(() => context);
builds: objData.builds.map(d => Build.fromJSON(d)),
groups: objData.groups.map(g => ({ ...g, artifactMatch: g.artifactMatch && deserializeRegExp(g.artifactMatch) }))