Add node modules and compiled JavaScript from main (#54)
Co-authored-by: Oliver King <oking3@uncc.edu>
This commit is contained in:
committed by
GitHub
parent
4a983766a0
commit
52d71d28bd
50
node_modules/tmp-promise/index.js
generated
vendored
Normal file
50
node_modules/tmp-promise/index.js
generated
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
'use strict';
|
||||
|
||||
const { promisify } = require("util");
|
||||
const tmp = require("tmp");
|
||||
|
||||
// file
|
||||
module.exports.fileSync = tmp.fileSync;
|
||||
const fileWithOptions = promisify((options, cb) =>
|
||||
tmp.file(options, (err, path, fd, cleanup) =>
|
||||
err ? cb(err) : cb(undefined, { path, fd, cleanup: promisify(cleanup) })
|
||||
)
|
||||
);
|
||||
module.exports.file = async (options) => fileWithOptions(options);
|
||||
|
||||
module.exports.withFile = async function withFile(fn, options) {
|
||||
const { path, fd, cleanup } = await module.exports.file(options);
|
||||
try {
|
||||
return await fn({ path, fd });
|
||||
} finally {
|
||||
await cleanup();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// directory
|
||||
module.exports.dirSync = tmp.dirSync;
|
||||
const dirWithOptions = promisify((options, cb) =>
|
||||
tmp.dir(options, (err, path, cleanup) =>
|
||||
err ? cb(err) : cb(undefined, { path, cleanup: promisify(cleanup) })
|
||||
)
|
||||
);
|
||||
module.exports.dir = async (options) => dirWithOptions(options);
|
||||
|
||||
module.exports.withDir = async function withDir(fn, options) {
|
||||
const { path, cleanup } = await module.exports.dir(options);
|
||||
try {
|
||||
return await fn({ path });
|
||||
} finally {
|
||||
await cleanup();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// name generation
|
||||
module.exports.tmpNameSync = tmp.tmpNameSync;
|
||||
module.exports.tmpName = promisify(tmp.tmpName);
|
||||
|
||||
module.exports.tmpdir = tmp.tmpdir;
|
||||
|
||||
module.exports.setGracefulCleanup = tmp.setGracefulCleanup;
|
Reference in New Issue
Block a user