build icon indicating copy to clipboard operation
build copied to clipboard

remove `import { tmpName } from 'tmp-promise'` dependency

Open lukasholzer opened this issue 2 years ago • 6 comments

This dependency is not needed for creating a temp directory as node can do that:

import { tmpName } from 'tmp-promise'

const path = await tmpName({ template: 'netlify-test-socket-XXXXXX' })

can be converted to:

import { promises as fs } from 'fs'
import { tmpdir } from 'os'
import { join } from 'path'

const path = await fs.mkdtemp(join(tmpdir(), 'netlify-test-socket-'))

lukasholzer avatar Sep 30 '22 11:09 lukasholzer

@lukasholzer tmpName just generates a random file name using some random chars (and checks if they don't already exist) while fs.mkdtemp actually creates the directory. Should we be changing the behaviour here from just creating a valid temp dir name to actually creating the directory?

tinfoil-knight avatar Feb 18 '23 19:02 tinfoil-knight

Yea this is combined. We never just create a name without creating the dir. So we should replacing that + creating the dir with fs.mkdtemp

lukasholzer avatar Feb 20 '23 13:02 lukasholzer

may i work on it

muditgaur-1009 avatar Mar 09 '23 12:03 muditgaur-1009

may i work on it

Sure. Go ahead @muditgaur-1009. Let me know if you come across any issues while setting things up.

tinfoil-knight avatar Mar 09 '23 13:03 tinfoil-knight

@tinfoil-knight please review i have made the changes

muditgaur-1009 avatar Mar 10 '23 19:03 muditgaur-1009

As this dependency is only used in tests I would prefer to keep it. It has a bunch of convenient functions.

I noticed though that @netlify/build has it listed under dependencies, which is wrong as it is only used in tests. https://github.com/netlify/build/pull/5064

danez avatar Jun 09 '23 16:06 danez

This issue has been automatically marked as stale because it has not had activity in 1 year. It will be closed in 14 days if no further activity occurs. Thanks!

github-actions[bot] avatar Jul 27 '24 14:07 github-actions[bot]

This issue was closed because it had no activity for over 1 year.

github-actions[bot] avatar Aug 11 '24 14:08 github-actions[bot]