Skip to content

Commit 375a87a

Browse files
committed
Add script for rebuilding fixtures
1 parent a19875f commit 375a87a

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

scripts/rebuildFixtures.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import fs from 'fs'
2+
import postcss from 'postcss'
3+
import tailwind from '..'
4+
import CleanCSS from 'clean-css'
5+
6+
function build({ from, to, config }) {
7+
return new Promise((resolve, reject) => {
8+
console.log(`Processing ./${from}...`)
9+
10+
fs.readFile(`./${from}`, (err, css) => {
11+
if (err) throw err
12+
13+
return postcss([tailwind(config)])
14+
.process(css, {
15+
from: undefined,
16+
})
17+
.then(result => {
18+
fs.writeFileSync(`./${to}`, result.css)
19+
return result
20+
})
21+
.then(resolve)
22+
.catch(error => {
23+
console.log(error)
24+
reject()
25+
})
26+
})
27+
})
28+
}
29+
30+
console.info('\nRebuilding fixtures...\n')
31+
32+
Promise.all([
33+
build({
34+
from: '__tests__/fixtures/tailwind-input.css',
35+
to: '__tests__/fixtures/tailwind-output.css',
36+
config: {},
37+
}),
38+
build({
39+
from: '__tests__/fixtures/tailwind-input.css',
40+
to: '__tests__/fixtures/tailwind-output-important.css',
41+
config: { important: true },
42+
}),
43+
]).then(() => {
44+
console.log('\nFinished rebuilding fixtures.')
45+
console.log(
46+
'\nPlease triple check that the fixture output matches what you expect before committing this change.'
47+
)
48+
})

0 commit comments

Comments
 (0)