Giter Club home page Giter Club logo

tempfile's Introduction

tempfile

Get a random temporary file path

Checkout out tempy which is a better take on this module.

Install

npm install tempfile

Usage

import tempfile from 'tempfile';

tempfile();
//=> '/var/folders/3x/jf5977fn79jbglr7rk0tq4d00000gn/T/6271e235-13b9-4138-8b9b-ee2f26c09ce3'

API

tempfile(options?)

options

Type: object

extension

Type: string

A file extension to append to the path.

import tempfile from 'tempfile';

tempfile();
//=> '/var/folders/3x/jf5977fn79jbglr7rk0tq4d00000gn/T/6271e235-13b9-4138-8b9b-ee2f26c09ce3'

tempfile({extension: 'png'});
//=> '/var/folders/3x/jf5977fn79jbglr7rk0tq4d00000gn/T/4049f192-43e7-43b2-98d9-094e6760861b.png'

Related

  • tempy - Get a random temporary file or directory path
  • temp-write - Write string/buffer/stream to a random temp file

tempfile's People

Contributors

bendingbender avatar munter avatar richienb avatar sindresorhus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

tempfile's Issues

Recently added TypeScript definition breaks ES6 imports

Hello!

I have a project which uses tempfile as an ES6 import in TypeScript, importing as follows:

import * as tempfile from "tempfile"

This used to work, but as of the latest version, I instead see:

This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export

I can't turn this on as it breaks other things.

The definition looks similar to what was already in https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/tempfile so I'm not sure what caused this exactly.

Thanks.

Import Issue

Hi,
I've installed tempfile in my Node, Express, Typescript project. But I am getting while importing it.
Error is as follows
require() of ES Module /Users/chanondler/Desktop/repos/mirage-api-v2/node_modules/tempfile/index.js from /Users/chanondler/Desktop/repos/mirage-api-v2/dist/src/controllers/lead.controller.js not supported.\nInstead change the require of index.js in /Users/chanondler/Desktop/repos/mirage-api-v2/dist/src/controllers/lead.controller.js to a dynamic import() which is available in all CommonJS modules."

Tried

  • import tempfile from "tempfile";
  • let tempfile = require('tempfile')
  • let tempfile: any; import("tempfile").then((res) => (tempfile = res.default));

But none of the above work
System and App configuration
Nodejs v17.4.0
Express v4.16
Tempfile v4.0.0
Macbook air M1

Why is tempy better?

Hi! Someone on my team started using tempfile (this library) and it works fine. Is there a risk/what's the reason we should switch to tempy?

vite: error: require is not defined: due to temp-dir being v2

error   require is not defined
  File:
    /home/brian/work/portfoliome/censible-core/apps/mi-www/@fs/home/brian/work/portfoliome/censible-core/node_modules/.pnpm/[email protected]/node_modules/temp-dir/index.js:4:12
  Stacktrace:
ReferenceError: require is not defined
    at eval (/home/brian/work/portfoliome/censible-core/node_modules/.pnpm/[email protected]/node_modules/temp-dir/index.js:4:12)
    at instantiateModule (file:///home/brian/work/portfoliome/censible-core/node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/chunks/dep-3007b26d.js:52400:15)

I noticed that temp-dir v3 supports ESM. Looks like an upgrade is needed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.