How to use temp-file - 5 common examples

To help you get started, we’ve selected a few temp-file 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 electron-userland / electron-builder / test / src / helpers / packTester.ts View on Github external
if (checkOptions.signed) {
    packagerOptions = signed(packagerOptions)
  }
  if (checkOptions.signedWin) {
    configuration.cscLink = WIN_CSC_LINK
    configuration.cscKeyPassword = ""
  }
  else if ((configuration as Configuration).cscLink == null) {
    packagerOptions = deepAssign({}, packagerOptions, {config: {mac: {identity: null}}})
  }

  const projectDirCreated = checkOptions.projectDirCreated
  let projectDir = path.join(__dirname, "..", "..", "fixtures", fixtureName)
  // const isDoNotUseTempDir = platform === "darwin"
  const customTmpDir = process.env.TEST_APP_TMP_DIR
  const tmpDir = checkOptions.tmpDir || new TmpDir(`pack-tester: ${fixtureName}`)
  // non-macOS test uses the same dir as macOS test, but we cannot share node_modules (because tests executed in parallel)
  const dir = customTmpDir == null ? await tmpDir.createTempDir({prefix: "test-project"}) : path.resolve(customTmpDir)
  if (customTmpDir != null) {
    await emptyDir(dir)
    log.info({customTmpDir}, "custom temp dir used")
  }

  await copyDir(projectDir, dir, {
    filter: it => {
      const basename = path.basename(it)
      // if custom project dir specified, copy node_modules (i.e. do not ignore it)
      return (packagerOptions.projectDir != null || basename !== "node_modules") && (!basename.startsWith(".") || basename === ".babelrc")
    },
    isUseHardLink: USE_HARD_LINKS,
  })
  projectDir = dir
github irccloud / irccloud-desktop / scripts / sign.js View on Github external
exports.default = async function (configuration) {
    // log.info(configuration, 'sign config');
    // Only process on one hash, we set hashes manually to control the order
    if (configuration.hash === 'sha1') {
        return;
    }
    const vm = new _vm.VmManager();
    const tempDirManager = new tempFile.TmpDir('packager');

    
    // signtool.exe
    // const windowsCodeSign = require("app-builder-lib/out/codeSign/windowsCodeSign");
    // const vendorPath = await windowsCodeSign.getSignVendorPath();
    // const signTool = path.join(vendorPath, "windows-10", process.arch, "signtool.exe");

    // https://github.com/vcsjones/AzureSignTool
    const signTool = "azuresigntool";
    
    // Appending each sig puts it after the top one, so the order here is a bit odd
    // For 4 signatures, sign in the following order: 1 4 3 2

    // 1
    let argsSha256 = computeAzureSignToolArgs(configuration, vm, false);
    log.info({hash: 'sha256', path: configuration.path, tool: signTool}, 'signing');
github electron-userland / electron-webpack / test / src / helpers / helper.ts View on Github external
import { ElectronWebpackConfiguration } from "electron-webpack"
import { copy, emptyDir } from "fs-extra"
import MemoryFS from "memory-fs"
import * as path from "path"
import { TmpDir } from "temp-file"
import webpack, { Configuration, Stats } from "webpack"

export const tmpDir = new TmpDir()

export const rootDir = path.join(__dirname, "..", "..", "..")

export async function doTest(configurationFile: string, electronWebpackConfiguration?: ElectronWebpackConfiguration) {
  const projectDir = await getMutableProjectDir()
  const finalConfiguration = {projectDir, ...electronWebpackConfiguration}
  const configuration = await require(`electron-webpack/${configurationFile}`)({configuration: finalConfiguration, production: true})
  await testWebpack(configuration, projectDir)
}

export async function getMutableProjectDir(fixtureName = "simple") {
  const projectDir = process.env.TEST_APP_TMP_DIR || await tmpDir.getTempDir()
  await emptyDir(projectDir)
  await copy(path.join(rootDir, "test/fixtures", fixtureName), projectDir)
  return projectDir
}
github atomist / sdm-pack-spring / lib / aspect / classpathDependenciesAspect.ts View on Github external
async function getGradleClasspathDependencies(p: Project): Promise {
    const lp = p as LocalProject;
    const initScript = `allprojects {
    apply plugin: "java"
    task listCompilePath(dependsOn: configurations.compileClasspath) {
        doLast {
            println "classpath=\${configurations.testCompileClasspath.collect { File file -> file }.join('${path.delimiter}')}"
        }
    }
}`;
    const tempFile = await new TmpDir().getTempFile({prefix: "init", suffix: ".gradle"});
    await fs.writeFile(tempFile, initScript);
    const log = new StringCapturingProgressLog();
    await spawnLog(await determineGradleCommand(p), ["--init-script", tempFile, "listCompilePath"], {log, cwd: lp.baseDir});
    const result = /classpath=(.*)/.exec(log.log);
    if (result) {
        return result[1]
            .split(path.delimiter)
            .map(element => {
                return element.substr(element.lastIndexOf(path.sep) + 1);
            });
    } else {
        return [];
    }
}
github atomist / sdm-pack-spring / lib / aspect / classpathDependenciesAspect.ts View on Github external
async function getMavenClasspathDependencies(p: Project): Promise {
    const lp = p as LocalProject;
    const log = new StringCapturingProgressLog();
    const tempFile = await new TmpDir().getTempFile({prefix: "classpath", suffix: ".txt"});
    await spawnLog(await determineMavenCommand(p), ["dependency:build-classpath", `-Dmdep.outputFile=${tempFile}`], {log, cwd: lp.baseDir});
    const classpath = await fs.readFile(tempFile, "UTF-8");
    return classpath
        .split(path.delimiter)
        .map(element => {
            return element.substr(element.lastIndexOf(path.sep) + 1);
        });
}

temp-file

```typescript export function getTempName(prefix?: string | null | undefined): string;

MIT
Latest version published 4 years ago

Package Health Score

50 / 100
Full package analysis

Popular temp-file functions