How to use the tmp.setGracefulCleanup function in tmp

To help you get started, we’ve selected a few tmp 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 cliqz-oss / browser-core / tests / runners / ghostery-headless.js View on Github external
async function main() {
  // Package navigation-extension
  const browserCoreArtifact = await createNavigationExtension();
  const baseDirectory = process.cwd();
  const navigationExtensionPath = path.join(baseDirectory, browserCoreArtifact);

  // Move to a temporary directory
  tmp.setGracefulCleanup();
  const tempDir = tmp.dirSync();
  process.chdir(tempDir.name);

  // Package ghostery-extension
  const ghosteryExtensionPath = path.join(
    tempDir.name,
    await createGhosteryExtension(navigationExtensionPath),
  );
  console.log('>>>', ghosteryExtensionPath);

  // Move back to base directory
  process.chdir(baseDirectory);

  // Start tests
  runTests(ghosteryExtensionPath);
}
github Dickurt / vscode-php-formatter / extension.js View on Github external
function activate(context) {
    var config = vscode.workspace.getConfiguration('phpformatter');

    tmp.setGracefulCleanup();
    
    // Not supported until https://github.com/Microsoft/vscode/issues/239 is implemented.
    // var saveCommand = vscode.workspace.onDidSaveTextDocument(function(document) {
    //     if(config.get('onSave', false) == false) {
    //         return;
    //     }
    //     fix(document);
    // });
    var fixCommand = vscode.commands.registerCommand('phpformatter.fix', function() {
        fix(vscode.window.activeTextEditor.document);
    });

    if( config.get('notifications', false) &&       // Check whether we are allowed to show notifications
        config.get('pharPath', '') == '' &&         // Did the user not set a .phar path?
        config.get('composer', false) == false      // Did the user not set composer to true?
        ) {
github GoogleCloudPlatform / github-actions / setup-gcloud / src / setup-gcloud.ts View on Github external
async function run() {
  try {
    tmp.setGracefulCleanup();

    const version = core.getInput('version');
    if (!version) {
      throw new Error('Missing required parameter: `version`');
    }

    const serviceAccountEmail = core.getInput('service_account_email') || '';

    const serviceAccountKey = core.getInput('service_account_key');
    if (!serviceAccountKey) {
      throw new Error('Missing required input: `service_account_key`');
    }

    // install the gcloud is not already present
    let toolPath = toolCache.find('gcloud', version);
    if (!toolPath) {
github adobe-photoshop / generator-assets-automation / main.js View on Github external
ASSETS_PLUGIN_CHECK_INTERVAL = 1000, // one second
        FILES_TO_IGNORE = new RegExp("(.DS_Store)$|(desktop.ini)$", "i"),
        ERRORS_TXT = "errors.txt",
        MAX_CONCURRENT_COMPARE_JOBS = 10,
        GENERATOR_CONFIG_FILE = "generator.json",
        DEFAULT_MAX_COMPARE_METRIC = 10;

    var path = require("path"),
        childProcess = require("child_process"),
        Q = require("q"),
        tmp = require("tmp"),
        fse = require("fs-extra"),
        os = require("os");

    // clean up temp files even if there's an uncaught exception
    tmp.setGracefulCleanup(true);

    var _generator,
        _config,
        _logger,
        _assetsPluginDeferred = Q.defer(),
        _psExecutablePathPromise = null,
        _idleDeferred = null,
        _activeDeferred = Q.defer();

    function getAssetsPlugin() {
        return _assetsPluginDeferred.promise;
    }

    function _whenActive(plugin) {
        if (plugin.hasOwnProperty("_status")) {
            return plugin._status.whenActive();
github okonet / lint-staged / test / runAll.unmocked.spec.js View on Github external
import fs from 'fs-extra'
import path from 'path'
import tmp from 'tmp'

import execGitBase from '../src/execGit'
import runAll from '../src/runAll'

tmp.setGracefulCleanup()
jest.unmock('execa')

const testJsFilePretty = `module.exports = {
  foo: "bar"
};
`

const testJsFileUgly = `module.exports = {
    'foo': 'bar',
}
`

const testJsFileUnfixable = `const obj = {
    'foo': 'bar'
`
github wordup-dev / wordup-cli / src / commands / cloud / publish.js View on Github external
this.userToken = null;
    if(!projectToken){

      this.userToken = this.getUserAuthToken()
      if(!this.userToken){
        this.log('Please authenticate first with: wordup auth')
        this.exit(2)
      }else{
        this.api = new WordupAPI(this.wordupConfig)
      }
    }

    this.projectSlug = project.wPkg('slugName') || process.env.WORDUP_PROJECT_SLUG
    this.accessToken = projectToken || (project.config.accessToken ? project.config.accessToken : null)

    tmp.setGracefulCleanup()

    const tempFile = tmp.fileSync({
      prefix: "wordup-archive-",
      postfix: ".tar.gz"
    })

    const result = await this.createArchive(tempFile)

    if(result){
      this.log('---')
      this.log('Successfully uploaded project')
    }
  }
github CImrie / mongomem / src / MongoDBServer.js View on Github external
import {MongodHelper} from 'mongodb-prebuilt';
import uuid from 'uuid/v4';
import tmp from 'tmp';
import getport from 'get-port';
tmp.setGracefulCleanup();

let getHelper = () => {
  return new Promise(async (resolve, reject) => {
    server.port = await getport(server.port || 27017);
    server.storageEngine = server.storageEngine|| 'ephemeralForTest';
    server.tmpFile = tmp.dirSync({prefix: "mongomem-", unsafeCleanup: true});

    server.dbPath = server.dbPath || server.tmpFile.name;

    let mongodHelper = new MongodHelper(
      [
        '--port', server.port,
        '--storageEngine', server.storageEngine,
        '--dbpath', server.dbPath,
        '--noauth'
      ]
github isaacabraham / vsts-fsharp / Common / paketCredMgr.ts View on Github external
export async function setup() {
    tmp.setGracefulCleanup();
    let credentialProviderPath = path.join(__dirname, "CredentialProvider");

    if (!fs.existsSync(`${credentialProviderPath}/CredentialProvider.PaketTeamBuild.dll`)) {
      tl.warning(`'${credentialProviderPath}/CredentialProvider.PaketTeamBuild.dll' doesnt exist!`);
      tl.debug("Skipping 'NUGET_CREDENTIALPROVIDERS_PATH'.");
      return;
    } else {
      tl.debug(`Adding '${credentialProviderPath}' to 'NUGET_CREDENTIALPROVIDERS_PATH'`);
    }

    var orig = process.env["NUGET_CREDENTIALPROVIDERS_PATH"];
    var newCredPath = credentialProviderPath
    if (orig) {
      newCredPath = newCredPath + ";" + orig;
    }
github Crypto-Punkers / resolver-engine / src / resolvers / urlresolver.ts View on Github external
export function UrlResolver(): SubResolver {
  tmp.setGracefulCleanup();

  return (what: string, ctx: UrlResolverContext): Promise =>
    new Promise((resolve, reject) => {
      if (!isValidUri(what)) {
        return resolve(null);
      }

      tmp.file((err, path, fd) => {
        if (err) {
          return reject(err);
        }
        debug("Created temporary file: ", path);

        const req = request({ url: what, ...ctx.options });
        req
          .on("response", response => {
github nodkz / mongodb-memory-server / packages / mongodb-memory-server-core / src / MongoMemoryServer.ts View on Github external
import tmp from 'tmp';
import getPort from 'get-port';
import { generateDbName } from './util/db_util';
import MongoInstance from './util/MongoInstance';
import { MongoBinaryOpts } from './util/MongoBinary';
import {
  CallbackFn,
  DebugFn,
  MongoMemoryInstancePropT,
  StorageEngineT,
  SpawnOptions,
} from './types';
import { DirResult } from 'tmp';
import { isNullOrUndefined } from 'util';

tmp.setGracefulCleanup();

export interface MongoMemoryServerOptsT {
  instance?: MongoMemoryInstancePropT;
  binary?: MongoBinaryOpts;
  debug?: boolean;
  spawn?: SpawnOptions;
  autoStart?: boolean;
}

export interface MongoInstanceDataT {
  port: number;
  dbPath: string;
  dbName: string;
  ip: string;
  uri: string;
  storageEngine: StorageEngineT;