Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
static async zipFiles(files) {
let tmp = require('tmp-promise');
let dir = await tmp.dir(), path = require('path'), fs = require('fs-extra');
let filenames = await files.mapAsync(async file => {
let fullPath = path.join(dir.path, file.filename);
await fs.writeFileAsync(fullPath, file.data);
return fullPath;
});
let p7zip = new (require('node-7z')), zipFile = await tmp.tmpName() + '.zip';
await p7zip.add(zipFile, filenames);
await fs.removeAsync(dir.path);
return zipFile;
}
return fetchSBOLObjectRecursive(remoteConfig, new SBOLDocument(), type, objectUri).then((res) => {
return tmp.tmpName().then((tmpFilename) => {
return fs.writeFile(tmpFilename, serializeSBOL(res.sbol))
.then(() => Promise.resolve(tmpFilename))
})
})
}
function saveTempFile () {
return tmp.tmpName().then((tmpFilename) => {
return fs.writeFile(tmpFilename, serializeSBOL(sbol)).then(() => {
return Promise.resolve(tmpFilename)
})
})
}
function saveTempFile () {
return tmp.tmpName().then((tmpFilename) => {
return fs.writeFile(tmpFilename, serializeSBOL(sbol)).then(() => {
return Promise.resolve(tmpFilename)
})
})
}
return fetchSBOLObjectRecursive(sbol, type, objectUri, graphUri).then((res) => {
return tmp.tmpName().then((tmpFilename) => {
return fs.writeFile(tmpFilename, serializeSBOL(res.sbol))
.then(() => Promise.resolve(tmpFilename))
})
})
}
async function renderSVG(image) {
debug('Generating SVG', image);
let path = await tmp.tmpName({ postfix: '.png' });
let buffer = Buffer.from(image.source);
try {
let result = await sharp(buffer, { density: 2400 } ).png().toFile(path);
} catch(e) {
throw e;
}
return path;
}
return fetchSBOLObjectNonRecursive(sbol, type, uri, graphUri).then((res) => {
return tmp.tmpName().then((tmpFilename) => {
return fs.writeFile(tmpFilename, serializeSBOL(res.sbol))
.then(() => Promise.resolve(tmpFilename))
})
})
} else {
function saveTempFile () {
return tmp.tmpName().then((tmpFilename) => {
return fs.writeFile(tmpFilename, serializeSBOL(sbol)).then(() => {
return Promise.resolve(tmpFilename)
})
})
}
function saveTempFile () {
return tmp.tmpName().then((tmpFilename) => {
return fs.writeFile(tmpFilename, serializeSBOL(sbol)).then(() => {
return Promise.resolve(tmpFilename)
})
})
}