Skip to content

Commit 51d0fe1

Browse files
committed
merge upstream
2 parents eda3848 + 4939f59 commit 51d0fe1

File tree

202 files changed

+42444
-37688
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

202 files changed

+42444
-37688
lines changed

.eslintignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
/lib
22
/docs
33
/__tests__/fixtures/cli-utils.js
4-
defaultConfig.stub.js
4+
/stubs/*

.eslintrc

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,8 @@
33
"jest": true
44
},
55
"parserOptions": {
6-
"ecmaVersion": 6,
7-
"sourceType": "module",
8-
"ecmaFeatures": {
9-
"experimentalObjectRestSpread": true
10-
}
6+
"ecmaVersion": 2018,
7+
"sourceType": "module"
118
},
129
"extends": ["eslint-config-postcss", "prettier"],
1310
"plugins": ["prettier"],

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/node_modules
22
/lib
33
/example
4+
index.html
5+
package-lock.json
46
yarn-error.log

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/__tests__/
22
/jest/
33
/src/
4+
index.html
45
yarn-error.log

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ For help, discussion about best practices, or any other conversation that would
2424

2525
For casual chit-chat with others using the framework:
2626

27-
[Join the Tailwind CSS Slack Community](https://join.slack.com/t/tailwindcss/shared_invite/enQtNDQ1MDYyNDA0NzA3LTAzOGEzYTRmMjE2OWUwMGViMGM2NGM5OWVmN2UzZjlmNzQ0ZTA2NGUwODYyOWMzNzM0M2MzMmE1NGYyNjk5NTI)
27+
[Join the Tailwind CSS Discord Server](https://discord.gg/7NF8GNe)
2828

2929
## Contributing
3030

__tests__/applyAtRule.test.js

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
import postcss from 'postcss'
22
import substituteClassApplyAtRules from '../src/lib/substituteClassApplyAtRules'
33
import processPlugins from '../src/util/processPlugins'
4+
import resolveConfig from '../src/util/resolveConfig'
45
import corePlugins from '../src/corePlugins'
5-
import defaultConfig from '../defaultConfig.stub.js'
6+
import defaultConfig from '../stubs/defaultConfig.stub.js'
67

7-
const { utilities: defaultUtilities } = processPlugins(corePlugins(defaultConfig), defaultConfig)
8+
const resolvedDefaultConfig = resolveConfig([defaultConfig])
89

9-
function run(input, config = defaultConfig, utilities = defaultUtilities) {
10+
const { utilities: defaultUtilities } = processPlugins(
11+
corePlugins(resolvedDefaultConfig),
12+
resolvedDefaultConfig
13+
)
14+
15+
function run(input, config = resolvedDefaultConfig, utilities = defaultUtilities) {
1016
return postcss([substituteClassApplyAtRules(config, utilities)]).process(input, {
1117
from: undefined,
1218
})
@@ -200,10 +206,12 @@ test('you can apply utility classes without using the given prefix', () => {
200206
.foo { margin-top: 1rem; margin-bottom: 1rem; }
201207
`
202208

203-
const config = {
204-
...defaultConfig,
205-
prefix: 'tw-',
206-
}
209+
const config = resolveConfig([
210+
{
211+
...defaultConfig,
212+
prefix: 'tw-',
213+
},
214+
])
207215

208216
return run(input, config, processPlugins(corePlugins(config), config).utilities).then(result => {
209217
expect(result.css).toEqual(expected)
@@ -220,12 +228,14 @@ test('you can apply utility classes without using the given prefix when using a
220228
.foo { margin-top: 1rem; margin-bottom: 1rem; }
221229
`
222230

223-
const config = {
224-
...defaultConfig,
225-
prefix: () => {
226-
return 'tw-'
231+
const config = resolveConfig([
232+
{
233+
...defaultConfig,
234+
prefix: () => {
235+
return 'tw-'
236+
},
227237
},
228-
}
238+
])
229239

230240
return run(input, config, processPlugins(corePlugins(config), config).utilities).then(result => {
231241
expect(result.css).toEqual(expected)

__tests__/cli.compile.test.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import path from 'path'
2+
3+
import autoprefixer from 'autoprefixer'
4+
5+
import tailwind from '../src'
6+
import compile from '../src/cli/compile'
7+
8+
describe('cli compile', () => {
9+
const inputFile = path.resolve(__dirname, 'fixtures/tailwind-input.css')
10+
const outputFile = 'output.css'
11+
const plugins = [tailwind(), autoprefixer]
12+
13+
it('compiles CSS file', () => {
14+
return compile({ inputFile, outputFile, plugins }).then(result => {
15+
expect(result.css).toContain('.example')
16+
expect(result.css).toContain('-ms-input-placeholder')
17+
})
18+
})
19+
})

__tests__/cli.test.js

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,43 @@
11
import path from 'path'
22

33
import cli from '../src/cli/main'
4-
import * as constants from '../src/cli/constants'
4+
import * as constants from '../src/constants'
55
import * as utils from '../src/cli/utils'
6+
import runInTempDirectory from '../jest/runInTempDirectory'
67

78
describe('cli', () => {
89
const inputCssPath = path.resolve(__dirname, 'fixtures/tailwind-input.css')
910
const customConfigPath = path.resolve(__dirname, 'fixtures/custom-config.js')
11+
const defaultConfigFixture = utils.readFile(constants.defaultConfigStubFile)
12+
const simpleConfigFixture = utils.readFile(constants.simpleConfigStubFile)
1013

1114
beforeEach(() => {
1215
console.log = jest.fn()
1316
process.stdout.write = jest.fn()
14-
utils.writeFile = jest.fn()
1517
})
1618

1719
describe('init', () => {
1820
it('creates a Tailwind config file', () => {
19-
return cli(['init']).then(() => {
20-
expect(utils.writeFile.mock.calls[0][0]).toEqual(constants.defaultConfigFile)
21+
return runInTempDirectory(() => {
22+
return cli(['init']).then(() => {
23+
expect(utils.readFile(constants.defaultConfigFile)).toEqual(simpleConfigFixture)
24+
})
2125
})
2226
})
2327

24-
it('creates a Tailwind config file in a custom location', () => {
25-
return cli(['init', 'custom.js']).then(() => {
26-
expect(utils.writeFile.mock.calls[0][0]).toEqual('custom.js')
28+
it('creates a full Tailwind config file', () => {
29+
return runInTempDirectory(() => {
30+
return cli(['init', '--full']).then(() => {
31+
expect(utils.readFile(constants.defaultConfigFile)).toEqual(defaultConfigFixture)
32+
})
2733
})
2834
})
2935

30-
it('creates a Tailwind config file without comments', () => {
31-
return cli(['init', '--no-comments']).then(() => {
32-
expect(utils.writeFile.mock.calls[0][1]).not.toContain('/**')
33-
expect(utils.writeFile.mock.calls[0][1]).toContain('//')
36+
it('creates a Tailwind config file in a custom location', () => {
37+
return runInTempDirectory(() => {
38+
return cli(['init', 'custom.js']).then(() => {
39+
expect(utils.exists('custom.js')).toEqual(true)
40+
})
3441
})
3542
})
3643
})
@@ -49,9 +56,10 @@ describe('cli', () => {
4956
})
5057

5158
it('creates compiled CSS file', () => {
52-
return cli(['build', inputCssPath, '--output', 'output.css']).then(() => {
53-
expect(utils.writeFile.mock.calls[0][0]).toEqual('output.css')
54-
expect(utils.writeFile.mock.calls[0][1]).toContain('.example')
59+
return runInTempDirectory(() => {
60+
return cli(['build', inputCssPath, '--output', 'output.css']).then(() => {
61+
expect(utils.readFile('output.css')).toContain('.example')
62+
})
5563
})
5664
})
5765

__tests__/cli.utils.test.js

Lines changed: 7 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
import path from 'path'
21
import * as utils from '../src/cli/utils'
32

43
describe('cli utils', () => {
5-
const fixture = utils.readFile(path.resolve(__dirname, 'fixtures/cli-utils.js'))
6-
74
describe('parseCliParams', () => {
85
it('parses CLI parameters', () => {
96
const result = utils.parseCliParams(['a', 'b', '-c', 'd'])
@@ -60,52 +57,17 @@ describe('cli utils', () => {
6057
})
6158
})
6259

63-
describe('stripBlockComments', () => {
64-
it('does not strip code', () => {
65-
const result = utils.stripBlockComments(fixture)
66-
67-
expect(result).toEqual(expect.stringContaining('__code_no_comment__'))
68-
expect(result).toEqual(expect.stringContaining('__code_comment_line__'))
69-
expect(result).toEqual(expect.stringContaining('__code_comment_block__'))
70-
expect(result).toEqual(expect.stringContaining('__code_comment_line_important__'))
71-
expect(result).toEqual(expect.stringContaining('__code_comment_block_important__'))
72-
})
73-
74-
it('strips block comments', () => {
75-
const result = utils.stripBlockComments(fixture)
76-
77-
expect(result).not.toEqual(expect.stringContaining('__comment_block__'))
78-
expect(result).not.toEqual(expect.stringContaining('__comment_block_multiline__'))
79-
expect(result).not.toEqual(expect.stringContaining('__comment_block_code__'))
80-
})
81-
82-
it('strips docblock comments', () => {
83-
const result = utils.stripBlockComments(fixture)
84-
85-
expect(result).not.toEqual(expect.stringContaining('__comment_docblock__'))
86-
})
87-
88-
it('does not strip line comments', () => {
89-
const result = utils.stripBlockComments(fixture)
90-
91-
expect(result).toEqual(expect.stringContaining('__comment_line__'))
92-
expect(result).toEqual(expect.stringContaining('__comment_line_important__'))
93-
expect(result).toEqual(expect.stringContaining('__comment_line_code__'))
94-
expect(result).toEqual(expect.stringContaining('__comment_line_important_code__'))
95-
})
96-
97-
it('does not strip important block comments', () => {
98-
const result = utils.stripBlockComments(fixture)
60+
describe('getSimplePath', () => {
61+
it('strips leading ./', () => {
62+
const result = utils.getSimplePath('./test')
9963

100-
expect(result).toEqual(expect.stringContaining('__comment_block_important__'))
101-
expect(result).toEqual(expect.stringContaining('__comment_block_multiline_important__'))
102-
expect(result).toEqual(expect.stringContaining('__comment_block_important_code__'))
64+
expect(result).toEqual('test')
10365
})
10466

105-
it('does not strip important docblock comments', () => {
106-
const result = utils.stripBlockComments(fixture)
67+
it('returns unchanged path if it does not begin with ./', () => {
68+
const result = utils.getSimplePath('../test')
10769

108-
expect(result).toEqual(expect.stringContaining('__comment_docblock_important__'))
70+
expect(result).toEqual('../test')
10971
})
11072
})
11173
})

0 commit comments

Comments
 (0)