From 291803c31f829fe0d32bb3207bc11def95a7408c Mon Sep 17 00:00:00 2001 From: Nevena Bojovic Date: Tue, 1 Mar 2022 20:05:50 +0100 Subject: Urađena test aplikacija. Povezan front i back. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../node_modules/@npmcli/fs/lib/with-temp-dir.js | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 sandbox/testAppNevena/Front/node_modules/@npmcli/fs/lib/with-temp-dir.js (limited to 'sandbox/testAppNevena/Front/node_modules/@npmcli/fs/lib/with-temp-dir.js') diff --git a/sandbox/testAppNevena/Front/node_modules/@npmcli/fs/lib/with-temp-dir.js b/sandbox/testAppNevena/Front/node_modules/@npmcli/fs/lib/with-temp-dir.js new file mode 100644 index 00000000..353d5555 --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/@npmcli/fs/lib/with-temp-dir.js @@ -0,0 +1,39 @@ +const { join, sep } = require('path') + +const getOptions = require('./common/get-options.js') +const mkdir = require('./mkdir/index.js') +const mkdtemp = require('./mkdtemp.js') +const rm = require('./rm/index.js') + +// create a temp directory, ensure its permissions match its parent, then call +// the supplied function passing it the path to the directory. clean up after +// the function finishes, whether it throws or not +const withTempDir = async (root, fn, opts) => { + const options = getOptions(opts, { + copy: ['tmpPrefix'], + }) + // create the directory, and fix its ownership + await mkdir(root, { recursive: true, owner: 'inherit' }) + + const target = await mkdtemp(join(`${root}${sep}`, options.tmpPrefix || ''), { owner: 'inherit' }) + let err + let result + + try { + result = await fn(target) + } catch (_err) { + err = _err + } + + try { + await rm(target, { force: true, recursive: true }) + } catch (err) {} + + if (err) { + throw err + } + + return result +} + +module.exports = withTempDir -- cgit v1.2.3