Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.1.2 #5

Merged
merged 2 commits into from
Aug 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ var slicedToArray = (function() {

//

const PUT_EXPRESSION = ['/', './', '*']
const CWD_PATHS = ['.', './'].map(path.normalize)
const PUT_EXPRESSION = ['/', '.', './', '*']

var prepare = (put, out, processors, ignored) => {
let map, f2t
Expand Down Expand Up @@ -145,7 +146,7 @@ const recursiveSettingMap = (put, ignored, f2t, map) =>
const createEgg = (filepath, put, out, processors = {}) =>
Egg(
filepath,
path.join(out, filepath.split(put)[1]),
path.join(out, CWD_PATHS.includes(put) ? filepath : filepath.split(put)[1]),
processors[path.extname(filepath).slice(1)] || {}
)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chin",
"version": "3.1.1",
"version": "3.1.2",
"repository": "chinjs/chin",
"author": "kthjm <toxictoxer@gmail.com>",
"license": "MIT",
Expand Down
7 changes: 4 additions & 3 deletions src/prepare.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow
import recursiveReaddir from 'recursive-readdir'
import { join, extname } from 'path'
import { normalize, join, extname } from 'path'
import {
type Path,
type Processors,
Expand All @@ -9,7 +9,8 @@ import {
type F2TFn
} from '../types.js'

const PUT_EXPRESSION = ['/', './', '*']
const CWD_PATHS = ['.', './'].map(normalize)
const PUT_EXPRESSION = ['/', '.', './', '*']

export default (
put: Path,
Expand Down Expand Up @@ -64,7 +65,7 @@ const recursiveSettingMap = (put, ignored, f2t, map) =>
const createEgg = (filepath, put, out, processors = {}) =>
Egg(
filepath,
join(out, filepath.split(put)[1]),
join(out, CWD_PATHS.includes(put) ? filepath : filepath.split(put)[1]),
processors[extname(filepath).slice(1)] || {}
)

Expand Down
11 changes: 11 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ const tree = {
}
}

describe('chin({ put: [cwd] })', () => {
beforeEach(() => mock(tree))
afterEach(() => mock.restore())

const test = (put) => () =>
chin({ put, out })

it('.', test('.'))
it('./', test('./'))
})

describe('chin', () => {

beforeEach(() => mock(tree))
Expand Down