How to use the tmp.dirSync 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 electrode-io / electrode-native / system-tests / system-tests.js View on Github external
function runTest(testSourceFile) {
  // No Cauldron should be active when starting a test suite
  run('cauldron repo clear')
  // Trace log level should be set to trace to ensure that `ora`
  // gets disabled as it can lead to issues on CI env
  run('platform config set logLevel trace')
  // Disable banner before running a test suite
  // to reduce log verbosity
  run('platform config set showBanner false')
  const workingDirPath = tmp.dirSync({ unsafeCleanup: true }).name
  process.chdir(workingDirPath)
  console.log(`Running ${testSourceFile} tests`)
  require(path.join(pathToSystemTests, testSourceFile))
}
github realm / realm-js / tests / js / support / test-object-server.js View on Github external
constructor() {
        super();
        const SyncServer = require('realm-sync-server').RealmSyncServer;

        this._key = new NodeRSA({b: 2048});
        this.adminToken = signAdminToken(this._key, token);
        this.httpPort = 9090;
        this.adminUser = Realm.Sync.User.login(`http://127.0.0.1:${this.httpPort}`,
                                               Realm.Sync.Credentials.adminToken(this.adminToken));

        this._temp = tmp.dirSync({ unsafeCleanup: true});
        fs.writeFileSync(path.join(this._temp.name, 'public.pem'), this._key.exportKey('public'));
        this._writeConfiguration();

        this._server = new SyncServer({dataPath: this._temp.name,
                                       publicKeyPath: path.join(this._temp.name, 'public.pem'),
                                       listenAddress: '127.0.0.1',
                                       listenPort: `${this.httpPort + 1}`,
                                       logCallback: this._syncLogCallback.bind(this),
                                       featureToken: process.env.SYNC_WORKER_FEATURE_TOKEN
        });
        this._proxy = new SyncServerProxy(this.httpPort, this.httpPort + 1);
    }
github realm / realm-js / tests / js / adapter-tests.ts View on Github external
}
];

var RANDOM_DATA = new Uint8Array([
    0xd8, 0x21, 0xd6, 0xe8, 0x00, 0x57, 0xbc, 0xb2, 0x6a, 0x15, 0x77, 0x30, 0xac, 0x77, 0x96, 0xd9,
    0x67, 0x1e, 0x40, 0xa7, 0x6d, 0x52, 0x83, 0xda, 0x07, 0x29, 0x9c, 0x70, 0x38, 0x48, 0x4e, 0xff,
]);

var nextChangePromise = undefined;
var nextAvailablePromise = undefined;
var adapter;
var rosController;

let tmpDir;

const realmNamePrefix = path.basename(tmp.dirSync().name);
let currentTestName: String;
jasmine.getEnv().addReporter({
    specStarted: (result) => {
        currentTestName = result.fullName.replace(/ /g, '_').replace('Adapter', realmNamePrefix);
    }
});
Realm.Sync.setLogLevel('error');

describe('Adapter', () => {
    beforeEach(async () => {
        Realm.clearTestState();
        tmpDir = tmp.dirSync({unsafeCleanup: true});

        if (useTestServer) {
            rosController = new TestObjectServer();
        } else {
github realm / realm-graphql / tests / GraphQLTestServer.ts View on Github external
public async start(params: any = {}) {
    this.tmpDir = tmp.dirSync();
    return super.start({
      dataPath: this.tmpDir.name,
      address: '127.0.0.1',
      httpsAddress: '127.0.0.1',
      port: 0,
      ...params
    });
  }
github plasma-umass / Stopify / examples / server / src / server.js View on Github external
function viaFission(jsCode, callback) {
  const dir = tmp.dirSync().name;  
  const appJs = dir + '/app.js';
  const clientJs = dir + '/app-client.js';
  fs.writeFileSync(appJs, jsCode);
  spawn('npm', ['link', 'fission'], { cwd: dir }).on('exit', runFission);

  function runFission() {
    console.log("Runnign Fission");
    console.log(dir);
    spawn('fission', ['app.js'], { cwd: dir }).on('exit', readStoppableJs);
  }

  function readStoppableJs() {
    callback(fs.readFileSync(__dirname + '/stop_event_receiver.js', 'utf8') + "\n" +
             fs.readFileSync(clientJs, 'utf8'));
  }
}
github broidHQ / integrations / broid-wechat / lib / core / Adapter.js View on Github external
uploadFile(url, fType, file) {
        const tmpdir = tmp.dirSync().name;
        const filePath = path.join(tmpdir, file);
        const fileStream = fs.createWriteStream(filePath);
        return new Promise((resolve, reject) => {
            request(url)
                .pipe(fileStream)
                .on('error', (err) => {
                reject(err);
            })
                .on('close', () => {
                fileStream.close();
                resolve();
            });
        })
            .then(() => this.client.uploadMediaAsync(filePath, fType))
            .then((res) => {
            fs.removeSync(tmpdir);
github httptoolkit / mockttp / karma.conf.js View on Github external
devtool: 'source-map',
            resolve: { extensions: ['.ts', '.js'] },
            module: {
                loaders: [
                    { test: /fs-extra/, loader: 'null-loader' },
                    { test: /\.ts$/, loader: 'ts-loader', exclude: /node_modules/ }
                ]
            },
            node: {
                fs: 'empty',
                net: 'empty',
                tls: 'empty',
                __dirname: true
            },
            output: {
                path: tmp.dirSync()
            }
        },
        webpackMiddleware: {
            stats: 'error-only'
        },
        preprocessors: {
            'src/**/*.ts': ['webpack', 'sourcemap'],
            'test/**/*.ts': ['webpack', 'sourcemap']
        },
        reporters: ['progress'],
        port: 9876,
        logLevel: config.LOG_INFO,

        browsers: ['ChromeHeadlessWithCert'],
        customLaunchers: {
            ChromeHeadlessWithCert: {
github quanglam2807 / singlebox / public / libs / workspaces.js View on Github external
.then(() => {
      if (isUrl(sourcePicturePath)) {
        const tmpObj = tmp.dirSync();
        const tmpPath = tmpObj.name;
        return download(sourcePicturePath, tmpPath, {
          filename: 'e.png',
        }).then(() => path.join(tmpPath, 'e.png'));
      }

      return sourcePicturePath;
    })
    .then((picturePath) => Jimp.read(picturePath))
github informalsystems / themis-contract / src / shared / contract.ts View on Github external
private async compileWithTectonic(inputFile: string, outputFile: string) {
    const tmpOutDir = tmp.dirSync()
    const infParsed = path.parse(inputFile)
    try {
      const tectonic = await spawnAsync(
        'tectonic',
        [inputFile, '-o', tmpOutDir.name],
        {},
      )
      logger.debug(`tectonic stdout:\n${tectonic.stdout}`)
      logger.debug(`tectonic stderr:\n${tectonic.stderr}`)
      if (tectonic.status !== 0) {
        throw new Error(
          `tectonic failed with exit code: ${tectonic.status}:\n${tectonic.stderr}`,
        )
      }
      const tmpOutFile = path.join(tmpOutDir.name, `${infParsed.name}.pdf`)
      logger.debug(`Temporary output file should be at: ${tmpOutFile}`)