How to use the tmp-promise.dirSync 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 zeit / now / test / integration.js View on Github external
test('initialize selected example ("amp")', async t => {
  tmpDir = tmp.dirSync({ unsafeCleanup: true });
  const cwd = tmpDir.name;
  const goal = '> Success! Initialized "amp" example in';

  const { stdout, stderr, code } = await execute(['init'], {
    cwd,
    input: '\n'
  });

  t.is(code, 0, formatOutput({ stdout, stderr }));
  t.true(stdout.includes(goal), formatOutput({ stdout, stderr }));
  t.true(verifyExampleAmp(cwd, 'amp'), formatOutput({ stdout, stderr }));
});
github electron-userland / electron-installer-snap / test / _util.js View on Github external
test.beforeEach(t => {
  t.context.tempDir = tmp.dirSync({ prefix: 'electron-installer-snap-' })
  process.chdir(t.context.tempDir.name)
})
github atomist / automation-client / test / project / utils.ts View on Github external
export function tempProject(id: RepoRef = {
    owner: "dummyOwner",
    repo: "dummyRepo",
    url: "",
}): LocalProject & ScriptedFlushable {
    const dir = tmp.dirSync({ unsafeCleanup: true });
    return new NodeFsLocalProject(id, dir.name, async () => dir.removeCallback()) as any as LocalProject & ScriptedFlushable;
}
github farism / elm-factory / src / gulp-elm-css.js View on Github external
const transform = function(file, encode, callback) {
    if (file.isStream()) {
      this.emit(
        'error',
        new gutil.PluginError(PLUGIN, 'Streams are not supported!'),
      )
      return callback()
    }

    const {cwd, module, out, port} = Object.assign({}, defaults, options)
    const tmpDir = tmp.dirSync({unsafeCleanup: true})
    const dir = out || tmpDir.name

    elmCss(cwd, file.path, dir, module, port)
      .then(() => glob(`${dir}/*.css`))
      .then(files =>
        Promise.all(files.map(file => fs.readFile(file))).then(allContent => {
          allContent.map((contents, i) => {
            this.push(
              new gutil.File({
                cwd: process.cwd(),
                path: path.basename(files[i]),
                contents,
              }),
            )
          })
        }),
github dsheiko / puppetry / src / component / Modal / ExportProjectModal.jsx View on Github external
defaultValue="jest"
                  >
                    <option value="jest">Jest/Puppeteer project (CI-friendly)</option>
                    <option value="text">test specification</option>
                  
                

                { format === "jest" &amp;&amp;  }

                { format === "text" &amp;&amp;  }

                

                

                
                  <p>Please select suites to export:</p>
                  <div>
                    
                    Check all
                    
                  </div>
github atomist / sdm-pack-spring / lib / spring / generate / springInitializrGenerator.ts View on Github external
function springInitializrProject(sdm: SoftwareDeliveryMachine, params: SpringInitializrProjectCreationParameters): Promise {
    const url = "https://start.spring.io/starter.zip";
    const tmpDir = tmp.dirSync({unsafeCleanup: true});
    const cwd = tmpDir.name;
    const lastSlash = url.lastIndexOf("/");
    const filename = url.substring(lastSlash + 1);
    const zipFile = path.join(cwd, filename);
    const urlParameters = getUrlParameters(params);
    const packageJson = require("../../../package.json");
    const headers = {
        "User-Agent": "atomist/sdm-pack-spring-" + packageJson.version,
    };
    return downloadFileAs(url, zipFile, urlParameters, headers)
        .then(() =&gt; decompress(zipFile, cwd))
        .then(() =&gt; fs.unlinkSync(zipFile))
        .then(() =&gt; new NodeFsLocalProject("spring-initializr-project", cwd));
}
github atomist / sdm / src / internal / artifact / github / GitHubReleaseArtifactStore.ts View on Github external
public async checkout(url: string, id: RemoteRepoRef, creds: ProjectOperationCredentials): Promise {
        logger.info("Attempting to download artifact [%s] for %j", url, id);
        const tmpDir = tmp.dirSync({unsafeCleanup: true});
        const cwd = tmpDir.name;
        const lastSlash = url.lastIndexOf("/");
        const filename = url.substring(lastSlash + 1);
        const re = /([a-zA-Z0-9_]+)-(.*)/;
        const match = re.exec(filename);
        const name = match[1];
        const version = match[2].replace(/.jar$/, "");

        const outputPath = cwd + "/" + filename;
        logger.info("Attempting to download url %s to %s", url, outputPath);
        await downloadFileAs(creds, url, outputPath);
        logger.info("Successfully download url %s to %s", url, outputPath);
        return {
            cwd,
            filename,
            name,
github atomist / sdm / src / util / project / filter.ts View on Github external
export async function filtered(p: LocalProject, globs: string[]): Promise {
    if (!globs) {
        logger.debug("Cannot filter project %j: No globs specified", p.id);
        return p;
    }
    const tmpDir = tmp.dirSync({unsafeCleanup: true}).name;
    logger.info("Filtered project %j at %d to %s", p.id, p.baseDir, tmpDir);
    await Promise.all(globs.map(glob =&gt;
        doWithFiles(p, glob, async f =&gt; {
            await promisify(fs.copyFile)(
                p.baseDir + "/" + f.path,
                tmpDir + "/" + f.path);
        })));
    return new NodeFsLocalProject(p.id, tmpDir);
}
github dsheiko / puppetry / src / __e2e__ / lib / bootstrap.js View on Github external
createTmpDir( key ) {
    this.tmpDir[ key ] = tmp.dirSync().name;
  }

tmp-promise

The tmp package with promises support and disposers.

MIT
Latest version published 3 years ago

Package Health Score

73 / 100
Full package analysis