-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #314 from posthtml/milestone-0.7.3
Milestone 0.7.3
- Loading branch information
Showing
13 changed files
with
184 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
"@babel/preset-env", | ||
{ | ||
"targets": { | ||
"node": 8 | ||
"node": 10 | ||
} | ||
} | ||
], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
'input': 'src/**/*.html' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
'output': 'dist/output.html' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
'output': 'dist/output.html' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,5 @@ | ||
{ | ||
"input": [ | ||
"test/fixtures/by-config/two-io/input-1.html", | ||
"test/fixtures/by-config/two-io/input-2.html" | ||
], | ||
"output": "test/expected/by-config/two-io/", | ||
"input": "test/fixtures/by-config/one-io/input.html", | ||
"output": "test/expected/by-config/one-io/output.html", | ||
"plugins": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
{ | ||
"input": "test/fixtures/by-config/one-io/input.html", | ||
"output": "test/expected/by-config/one-io/output.html", | ||
"input": [ | ||
"test/fixtures/by-config/two-io/input-1.html", | ||
"test/fixtures/by-config/two-io/input-2.html" | ||
], | ||
"output": "test/expected/by-config/two-io/", | ||
"plugins": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,82 +1,147 @@ | ||
import test from 'ava'; | ||
import path from 'path'; | ||
import cfgResolve from '../lib/cfg-resolve'; | ||
|
||
test('should return function', t => { | ||
t.true(typeof cfgResolve === 'function'); | ||
}); | ||
|
||
test('should return config with one use key without property', async t => { | ||
test('should throw error `input files not found`', t => { | ||
const error = t.throws(() => { | ||
cfgResolve({}); | ||
}, {instanceOf: TypeError}); | ||
|
||
t.is(error.message, 'input files not found'); | ||
}); | ||
|
||
test('should return simple config', t => { | ||
const input = 'input.html'; | ||
const flags = {}; | ||
const config = cfgResolve({input, flags}); | ||
const expected = { | ||
allInOutput: false, | ||
input: [path.resolve('input.html')], | ||
options: {}, | ||
output: undefined, | ||
plugins: { | ||
'posthtml-custom-elements': {} | ||
}, | ||
root: './' | ||
}; | ||
|
||
t.deepEqual(config, expected); | ||
}); | ||
|
||
test('should return config plugins with one use key without property', t => { | ||
const input = 'input.html'; | ||
const flags = { | ||
use: 'posthtml-bem' | ||
}; | ||
const config = await cfgResolve({flags}); | ||
const config = cfgResolve({input, flags}); | ||
const expected = {'posthtml-bem': {}}; | ||
|
||
t.deepEqual(config.plugins, expected); | ||
}); | ||
|
||
test('should return config with one use key with one property', async t => { | ||
test('should return config with one use key with one property', t => { | ||
const input = 'input.html'; | ||
const flags = { | ||
use: 'posthtml-bem', | ||
posthtmlBem: { | ||
prefix: '__' | ||
} | ||
}; | ||
const config = await cfgResolve({flags}); | ||
const config = cfgResolve({input, flags}); | ||
const expected = {'posthtml-bem': {prefix: '__'}}; | ||
|
||
t.deepEqual(config.plugins, expected); | ||
}); | ||
|
||
test('should return config with key config plugins', async t => { | ||
test('should return config with key config plugins', t => { | ||
const input = 'input.html'; | ||
const flags = { | ||
config: 'test/config/.config-plugins' | ||
}; | ||
const config = await cfgResolve({flags}); | ||
const config = cfgResolve({input, flags}); | ||
const expected = {'posthtml-bem': {}}; | ||
|
||
t.deepEqual(config.plugins, expected); | ||
}); | ||
|
||
test('should return config with key config options', async t => { | ||
test('should return config with key config options', t => { | ||
const input = 'input.html'; | ||
const flags = { | ||
config: 'test/config/.config-options' | ||
}; | ||
const config = await cfgResolve({flags}); | ||
const config = cfgResolve({input, flags}); | ||
const expected = {sync: true}; | ||
|
||
t.deepEqual(config.options, expected); | ||
}); | ||
|
||
test('should return config options', async t => { | ||
test('should return config options', t => { | ||
const input = 'input.html'; | ||
const flags = { | ||
options: {sync: true} | ||
}; | ||
const config = await cfgResolve({flags}); | ||
const config = cfgResolve({input, flags}); | ||
const expected = {sync: true}; | ||
|
||
t.deepEqual(config.options, expected); | ||
}); | ||
|
||
test('should return config with key config and use key', async t => { | ||
test('should return config with key config and use key', t => { | ||
const input = 'input.html'; | ||
const flags = { | ||
use: 'posthtml-assets', | ||
config: 'test/config/.config-plugins' | ||
}; | ||
const config = await cfgResolve({flags}); | ||
const config = cfgResolve({input, flags}); | ||
const expected = {'posthtml-bem': {}, 'posthtml-assets': {}}; | ||
|
||
t.deepEqual(config.plugins, expected); | ||
}); | ||
|
||
test('should return config when CLI params priority', async t => { | ||
test('should return config when input param from config', t => { | ||
const flags = { | ||
config: 'test/config/.config-input' | ||
}; | ||
const config = cfgResolve({flags}); | ||
const expected = [path.resolve('src/**/*.html')]; | ||
|
||
t.deepEqual(config.input, expected); | ||
}); | ||
|
||
test('should return config when output param from config', t => { | ||
const input = 'input.html'; | ||
const flags = { | ||
config: 'test/config/.config-output' | ||
}; | ||
const config = cfgResolve({input, flags}); | ||
const expected = 'dist/output.html'; | ||
|
||
t.deepEqual(config.output, expected); | ||
}); | ||
|
||
test('should return config when CLI input param priority', t => { | ||
const input = 'src/template/**/*.html'; | ||
const flags = { | ||
config: 'test/config/.config-input-priority' | ||
}; | ||
const config = await cfgResolve({input, flags}); | ||
const expected = 'src/template/**/*.html'; | ||
const config = cfgResolve({input, flags}); | ||
const expected = [path.resolve('src/template/**/*.html')]; | ||
|
||
t.deepEqual(config.input, expected); | ||
}); | ||
|
||
test('should return config when CLI output param priority', t => { | ||
const input = 'input.html'; | ||
const flags = { | ||
output: 'public/output.html', | ||
config: 'test/config/.config-output-priority' | ||
}; | ||
const config = cfgResolve({input, flags}); | ||
const expected = 'public/output.html'; | ||
|
||
t.deepEqual(config.output, expected); | ||
}); |
Oops, something went wrong.