Skip to content

Commit

Permalink
Add a test case for Flow + destructuring
Browse files Browse the repository at this point in the history
  • Loading branch information
kossnocorp committed Sep 15, 2017
1 parent fd9ec82 commit 6a7e447
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
9 changes: 9 additions & 0 deletions examples/flow/destructuring.js.flow
@@ -0,0 +1,9 @@
// @flow

const {format} = require('date-fns')
const {eo} = require('date-fns/locale')

const dateString : string = '2017-01-25T21:28:15.000Z'
const formatString : string = 'DD.MM.YYYY HH:mm:ss'
const result : string = format('2017-01-25T21:28:15.000Z', 'dddd, DD MMMM HH:mm:ss', {locale: eo})
console.log(result === 'merkredo, 25 januaro 21:28:15')
8 changes: 5 additions & 3 deletions examples/flow/package.json
Expand Up @@ -14,13 +14,15 @@
"build": "yarn run build-date-fns && yarn run flow-check && yarn run build-babel",
"flow-check": "flow check",
"build-date-fns": "env PACKAGE_OUTPUT_PATH=\"$(pwd)/node_modules/date-fns\" ../../scripts/build/package.sh",
"build-babel": "yarn run build-babel-example && yarn run build-babel-fp && yarn run build-babel-misc",
"build-babel": "yarn run build-babel-example && yarn run build-babel-fp && yarn run build-babel-misc && yarn build-babel-destructuring",
"build-babel-example": "mkdir -p dist && babel example.js.flow --out-file dist/example.js",
"build-babel-fp": "mkdir -p dist && babel fp.js.flow --out-file dist/fp.js",
"build-babel-misc": "mkdir -p dist && babel misc.js.flow --out-file dist/misc.js",
"test": "yarn run test-example && yarn run test-fp && yarn run test-misc",
"build-babel-destructuring": "mkdir -p dist && babel destructuring.js.flow --out-file dist/destructuring.js",
"test": "yarn run test-example && yarn run test-fp && yarn run test-misc && yarn run test-destructuring",
"test-example": "test $(env TZ=UTC node ./dist/example.js) = true",
"test-fp": "test $(env TZ=UTC node ./dist/fp.js) = true",
"test-misc": "test $(env TZ=UTC node ./dist/misc.js) = true"
"test-misc": "test $(env TZ=UTC node ./dist/misc.js) = true",
"test-destructuring": "test $(env TZ=UTC node ./dist/destructuring.js) = true"
}
}
3 changes: 3 additions & 0 deletions scripts/build/package.sh
Expand Up @@ -38,6 +38,9 @@ do
cp -r "./src/$fnDir" "$dir/esm/"
done

# Copy global flow typing
cp ./src/index.js.flow "$dir/esm/index.js.flow"

# Copy esm indices
cp ./src/esm/index.js "$dir/esm/index.js"
cp ./src/esm/fp/index.js "$dir/esm/fp/index.js"
Expand Down

0 comments on commit 6a7e447

Please sign in to comment.