How to use the tmp-promise.withDir function in tmp-promise

To help you get started, we’ve selected a few tmp-promise examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mozilla / addons-linter / tests / integration / run-as-production-env.js View on Github external
testRun.stdout.pipe(process.stdout);
    testRun.stderr.pipe(process.stderr);
    testRun.on('close', (exitCode) => {
      if (exitCode === 0) {
        resolve();
      } else {
        reject(new Error('Failed to run integration tests'));
      }
    });
  });
}

// Create a production-like environment in a temporarily created directory
// and then run the integration tests on it.
tmp
  .withDir((tmpDir) => {
    const tmpDirPath = tmpDir.path;
    const unpackedDirPath = path.join(tmpDirPath, 'package');

    return createPackage(tmpDirPath)
      .then((archiveFilePath) => unpackTarPackage(archiveFilePath, tmpDirPath))
      .then(() => installPackageDeps(unpackedDirPath))
      .then(() => runIntegrationTests(unpackedDirPath));
  }, tmpOptions)
  .catch((err) => {
    console.error(err.stack ? chalk.red(err.stack) : chalk.red(err));
    process.exit(1);
  });

tmp-promise

The tmp package with promises support and disposers.

MIT
Latest version published 3 years ago

Package Health Score

72 / 100
Full package analysis