Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test('xXx setup xXx', function (t) {
mkdtemp(TEMP_OPTIONS, function (er, tmpdir) {
t.ifError(er, 'temp directory exists')
testBase = path.resolve(tmpdir, SHORT_PATH)
testPath = path.resolve(tmpdir, LONG_PATH)
mkdirp(testPath, function (er) {
t.ifError(er, 'made test path')
writeFileSync(path.resolve(tmpdir, FIRST_FILE), new Buffer("c'est vraiment joli"))
writeFileSync(path.resolve(tmpdir, SECOND_FILE), new Buffer('oui oui'))
t.end()
})
})
})
function gqlTestExtraction({ entry, output, schemaLocation, overwriteFiles, importLocation }) {
tmp.dir({ unsafeCleanup: true}, (err, graphqlOutput, cleanup) => {
fs.readdir(entry, (err, files) => {
errorExit(err);
let finishedCount = 0;
files.forEach(file => {
fs.stat(path.join(entry, file), (err, stat) => {
errorExit(err);
if (stat.isFile() && file.includes(".js")) {
fs.readFile(path.join(entry, file), "utf8", (err, data) => {
errorExit(err);
const { queriesWritten } = gqlExtract({
source: data,
filePath: graphqlOutput
});
if (queriesWritten.size) {
queriesWritten.forEach((query, queryName) => {
errorExit(err);
test('replicate media + osm-p2p to syncfile', function (t) {
tmp.dir(function (err, dir, cleanup) {
t.error(err)
var mfeed = multifeed(ram, { valueEncoding: 'json' })
var media = blob()
var syncfile
var node = { type: 'node', lat: 1, lon: 2 }
mfeed.writer('default', function (err, w) {
t.error(err)
w.append(node, function (err) {
t.error(err)
setup()
})
})
function setup () {
req.busboy.on("file", function (fieldname, file, filename)
{
++filesCounter;
let fileSize = 0;
tmp.dir({dir: Config.tempFilesDir}, function _tempDirCreated (err, tempFolderPath)
{
if (isNull(err))
{
let newFileLocalPath = path.join(tempFolderPath, filename);
fstream = fs.createWriteStream(newFileLocalPath);
fstream.on("error", function ()
{
return callback(1, "Error saving file from request into temporary file");
});
file.on("data", function (data)
{
fileSize += data.length;
});
module.exports = function(cb) {
tmp.dir({
mode: '0755',
prefix: 'budo-'
},
function(err, filepath) {
if (!err) {
process.on('exit', remove)
process.on('SIGINT', exit)
process.on('uncaughtException', exit)
log.debug('temp directory created at', filepath)
}
cb(err, filepath)
function remove(err) {
try {
rimraf.sync(filepath)
return new Promise((resolve, reject) => {
tmp.dir({unsafeCleanup: true}, (err, path, cleanup) => {
if (err) {
reject(err);
} else {
Promise.resolve(npath.toPortablePath(path)).then(cb).then(result => {
cleanup();
resolve(result);
}, error => {
cleanup();
reject(error);
});
}
});
});
}
const preuploadMiddleware = (req, res, next) => {
req.imagesFolder = uuid.v4();
if (!tmpDir) {
tmpDir = tmp.dir((err, path) => {
tmpDir = path;
next();
});
} else {
next();
}
};
return new Promise(function (resolve, reject) {
tmp.setGracefulCleanup();
tmp.dir(value, function (err, dirPath, cleanupCallback) {
if (err) {
reject(new errors.Error('tmp.dir', err));
return;
}
resolve({
dirPath: dirPath,
cleanupCallback: cleanupCallback
});
});
});
};
return new Promise(function promisePrepareTmpFolder(resolve, reject) {
tmp.dir({
prefix: 'laravel_queue-',
unsafeCleanup: true
}, function tmpDirCallback(err, name) {
if (err) {
return reject(err);
}
fs.mkdir(name + '/Config-laravel')
.then(function tmpdirOk() {
resolve(name + '/Config-laravel');
});
});
});
};