forked from postcss/postcss-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenv.js
More file actions
24 lines (18 loc) · 652 Bytes
/
env.js
File metadata and controls
24 lines (18 loc) · 652 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import fs from 'node:fs/promises'
import path from 'path'
import { glob } from 'tinyglobby'
import tmp from './tmp.js'
export default async function (config, fixtures = '**/*', extension = 'cjs') {
const dir = tmp()
await fs.mkdir(dir, { recursive: true })
const list = await glob(fixtures, { cwd: 'test/fixtures' })
await Promise.all([
...list.map(async (item) => {
const dest = path.join(dir, item)
await fs.mkdir(path.dirname(dest), { recursive: true })
await fs.copyFile(path.join('test/fixtures', item), dest)
}),
fs.writeFile(path.join(dir, `postcss.config.${extension}`), config),
])
return dir
}