Skip to content
This repository was archived by the owner on Feb 8, 2020. It is now read-only.

Commit e5c0dd1

Browse files
author
Charlike Mike Reagent
committed
fix(releasing): update readme and travis
fix #118, fix #119 TAG: latest
1 parent e30e00a commit e5c0dd1

File tree

5 files changed

+21
-194
lines changed

5 files changed

+21
-194
lines changed

.helarc.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
"build": [
55
"hela clean",
66
"hela build:node"
7+
],
8+
"release": [
9+
"hela style",
10+
"hela build",
11+
"rm -rf ./dist/test.js",
12+
"npx -p node@8 new-release"
713
]
814
}
915
}

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ script: yarn test
2626

2727
after_success:
2828
- bash <(curl -s https://codecov.io/bash)
29-
- npx -p node@8 yarn run release
29+
- yarn hela release
3030

3131
branches:
3232
except:

.verb.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ You may also read the [Contributing Guide](./CONTRIBUTING.md). There, beside _"H
3939
- **Customization:** allows switching the parser, through `options.parse`
4040
- **Support for:** arrow functions, default parameters, generators and async/await functions
4141
- **Stable:** battle-tested in production and against all parsers - [espree][], [acorn][], [babylon][]
42-
- **Tested:** with [275+ tests](./test.js) for _200%_ coverage
42+
- **Tested:** with [370+ tests](./test.js) for _200%_ coverage
4343

4444
## Table of Contents
4545
<!-- toc -->

README.md

Lines changed: 12 additions & 190 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ You might also be interested in [hela](https://github.com/tunnckoCore/hela#readm
1212

1313
## Quality Assurance :100:
1414

15+
[![Code Climate][codeclimate-img]][codeclimate-url]
1516
[![Code Style Standard][standard-img]][standard-url]
1617
[![Linux Build][travis-img]][travis-url]
1718
[![Code Coverage][codecov-img]][codecov-url]
@@ -38,7 +39,7 @@ You may also read the [Contributing Guide](./CONTRIBUTING.md). There, beside _"H
3839
- **Customization:** allows switching the parser, through `options.parse`
3940
- **Support for:** arrow functions, default parameters, generators and async/await functions
4041
- **Stable:** battle-tested in production and against all parsers - [espree][], [acorn][], [babylon][]
41-
- **Tested:** with [275+ tests](./test.js) for _200%_ coverage
42+
- **Tested:** with [370+ tests](./test.js) for _200%_ coverage
4243

4344
## Table of Contents
4445
- [Install](#install)
@@ -49,10 +50,6 @@ You may also read the [Contributing Guide](./CONTRIBUTING.md). There, beside _"H
4950
* [Real anonymous function](#real-anonymous-function)
5051
* [Plugins Architecture](#plugins-architecture)
5152
- [API](#api)
52-
* [parseFunction](#parsefunction)
53-
* [.parse](#parse)
54-
* [.use](#use)
55-
* [.define](#define)
5653
* [Result](#result)
5754
- [Related](#related)
5855
- [Contributing](#contributing)
@@ -189,181 +186,6 @@ you can add more properties if you want.
189186
## API
190187
Review carefully the provided examples and the working [tests](./test/index.js).
191188

192-
### [parseFunction](src/index.js#L59)
193-
194-
> Initializes with optional `opts` object which is passed directly
195-
to the desired parser and returns an object
196-
with `.use` and `.parse` methods. The default parse which
197-
is used is [babylon][]'s `.parseExpression` method from `v7`.
198-
199-
**Params**
200-
201-
* `opts` **{Object}**: optional, merged with options passed to `.parse` method
202-
* `returns` **{Object}**: `app` object with `.use` and `.parse` methods
203-
204-
**Example**
205-
206-
```jsx
207-
const parseFunction = require('parse-function')
208-
209-
const app = parseFunction({
210-
ecmaVersion: 2017
211-
})
212-
213-
const fixtureFn = (a, b, c) => {
214-
a = b + c
215-
return a + 2
216-
}
217-
218-
const result = app.parse(fixtureFn)
219-
console.log(result)
220-
221-
// see more
222-
console.log(result.name) // => null
223-
console.log(result.isNamed) // => false
224-
console.log(result.isArrow) // => true
225-
console.log(result.isAnonymous) // => true
226-
227-
// array of names of the arguments
228-
console.log(result.args) // => ['a', 'b', 'c']
229-
230-
// comma-separated names of the arguments
231-
console.log(result.params) // => 'a, b, c'
232-
```
233-
234-
### [.parse](src/index.js#L98)
235-
236-
> Parse a given `code` and returns a `result` object
237-
with useful properties - such as `name`, `body` and `args`.
238-
By default it uses Babylon parser, but you can switch it by
239-
passing `options.parse` - for example `options.parse: acorn.parse`.
240-
In the below example will show how to use `acorn` parser, instead
241-
of the default one.
242-
243-
**Params**
244-
245-
* `code` **{Function|String}**: any kind of function or string to be parsed
246-
* `options` **{Object}**: directly passed to the parser - babylon, acorn, espree
247-
* `options.parse` **{Function}**: by default `babylon.parseExpression`, all `options` are passed as second argument to that provided function
248-
* `returns` **{Object}**: `result` see [result section](#result) for more info
249-
250-
**Example**
251-
252-
```jsx
253-
const acorn = require('acorn')
254-
const parseFn = require('parse-function')
255-
const app = parseFn()
256-
257-
const fn = function foo (bar, baz) { return bar * baz }
258-
const result = app.parse(fn, {
259-
parse: acorn.parse,
260-
ecmaVersion: 2017
261-
})
262-
263-
console.log(result.name) // => 'foo'
264-
console.log(result.args) // => ['bar', 'baz']
265-
console.log(result.body) // => ' return bar * baz '
266-
console.log(result.isNamed) // => true
267-
console.log(result.isArrow) // => false
268-
console.log(result.isAnonymous) // => false
269-
console.log(result.isGenerator) // => false
270-
```
271-
272-
### [.use](src/index.js#L168)
273-
> Add a plugin `fn` function for extending the API or working on the AST nodes. The `fn` is immediately invoked and passed with `app` argument which is instance of `parseFunction()` call. That `fn` may return another function that accepts `(node, result)` signature, where `node` is an AST node and `result` is an object which will be returned [result](#result) from the `.parse` method. This retuned function is called on each node only when `.parse` method is called.
274-
275-
_See [Plugins Architecture](#plugins-architecture) section._
276-
277-
**Params**
278-
279-
* `fn` **{Function}**: plugin to be called
280-
* `returns` **{Object}**: `app` instance for chaining
281-
282-
**Example**
283-
284-
```jsx
285-
// plugin extending the `app`
286-
app.use((app) => {
287-
app.define(app, 'hello', (place) => `Hello ${place}!`)
288-
})
289-
290-
const hi = app.hello('World')
291-
console.log(hi) // => 'Hello World!'
292-
293-
// or plugin that works on AST nodes
294-
app.use((app) => (node, result) => {
295-
if (node.type === 'ArrowFunctionExpression') {
296-
result.thatIsArrow = true
297-
}
298-
return result
299-
})
300-
301-
const result = app.parse((a, b) => (a + b + 123))
302-
console.log(result.name) // => null
303-
console.log(result.isArrow) // => true
304-
console.log(result.thatIsArrow) // => true
305-
306-
const result = app.parse(function foo () { return 123 })
307-
console.log(result.name) // => 'foo'
308-
console.log(result.isArrow) // => false
309-
console.log(result.thatIsArrow) // => undefined
310-
```
311-
312-
### [.define](src/index.js#L227)
313-
314-
> Define a non-enumerable property on an object. Just
315-
a convenience mirror of the [define-property][] library,
316-
so check out its docs. Useful to be used in plugins.
317-
318-
**Params**
319-
320-
* `obj` **{Object}**: the object on which to define the property
321-
* `prop` **{String}**: the name of the property to be defined or modified
322-
* `val` **{Any}**: the descriptor for the property being defined or modified
323-
* `returns` **{Object}**: `obj` the passed object, but modified
324-
325-
**Example**
326-
327-
```jsx
328-
const parseFunction = require('parse-function')
329-
const app = parseFunction()
330-
331-
// use it like `define-property` lib
332-
const obj = {}
333-
app.define(obj, 'hi', 'world')
334-
console.log(obj) // => { hi: 'world' }
335-
336-
// or define a custom plugin that adds `.foo` property
337-
// to the end result, returned from `app.parse`
338-
app.use((app) => {
339-
return (node, result) => {
340-
// this function is called
341-
// only when `.parse` is called
342-
343-
app.define(result, 'foo', 123)
344-
345-
return result
346-
}
347-
})
348-
349-
// fixture function to be parsed
350-
const asyncFn = async (qux) => {
351-
const bar = await Promise.resolve(qux)
352-
return bar
353-
}
354-
355-
const result = app.parse(asyncFn)
356-
357-
console.log(result.name) // => null
358-
console.log(result.foo) // => 123
359-
console.log(result.args) // => ['qux']
360-
361-
console.log(result.isAsync) // => true
362-
console.log(result.isArrow) // => true
363-
console.log(result.isNamed) // => false
364-
console.log(result.isAnonymous) // => true
365-
```
366-
367189
**[back to top](#thetop)**
368190

369191
### Result
@@ -385,11 +207,11 @@ that can be useful to determine what the function is - arrow, regular, async/awa
385207
**[back to top](#thetop)**
386208

387209
## Related
388-
- [acorn](https://www.npmjs.com/package/acorn): ECMAScript parser | [homepage](https://github.com/ternjs/acorn "ECMAScript parser")
210+
- [acorn](https://www.npmjs.com/package/acorn): ECMAScript parser | [homepage](https://github.com/acornjs/acorn "ECMAScript parser")
389211
- [babylon](https://www.npmjs.com/package/babylon): A JavaScript parser | [homepage](https://babeljs.io/ "A JavaScript parser")
390212
- [charlike-cli](https://www.npmjs.com/package/charlike-cli): Command line interface for the [charlike][] project scaffolder. | [homepage](https://github.com/tunnckoCore/charlike-cli#readme "Command line interface for the [charlike][] project scaffolder.")
391213
- [espree](https://www.npmjs.com/package/espree): An Esprima-compatible JavaScript parser built on Acorn | [homepage](https://github.com/eslint/espree "An Esprima-compatible JavaScript parser built on Acorn")
392-
- [hela](https://www.npmjs.com/package/hela): Powerful & flexible task runner framework in 80 lines, based on execa… [more](https://github.com/tunnckoCore/hela#readme) | [homepage](https://github.com/tunnckoCore/hela#readme "Powerful & flexible task runner framework in 80 lines, based on execa. Supports presets, a la ESLint but for tasks & npm scripts")
214+
- [hela](https://www.npmjs.com/package/hela): Powerful & flexible task runner framework in 80 lines, based on [execa… [more](https://github.com/tunnckoCore/hela#readme) | [homepage](https://github.com/tunnckoCore/hela#readme "Powerful & flexible task runner framework in 80 lines, based on [execa][]. Supports shareable configs, a la ESLint")
393215
- [parse-semver](https://www.npmjs.com/package/parse-semver): Parse, normalize and validate given semver shorthand (e.g. [email protected]) to object. | [homepage](https://github.com/tunnckocore/parse-semver#readme "Parse, normalize and validate given semver shorthand (e.g. [email protected]) to object.")
394216

395217
## Contributing
@@ -402,14 +224,14 @@ Please read the [Contributing Guide](./CONTRIBUTING.md) and [Code of Conduct](./
402224
- [codementor/tunnckoCore](https://codementor.io/tunnckoCore)
403225

404226
## License
405-
Copyright © 2016-2017, [Charlike Mike Reagent](https://i.am.charlike.online). Released under the [MIT License](LICENSE).
227+
Copyright © 2016, 2018, [Charlike Mike Reagent](https://i.am.charlike.online). Released under the [MIT License](LICENSE).
406228

407229
***
408230

409-
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on October 09, 2017._
231+
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on February 14, 2018._
410232
Project scaffolded and managed with [hela][].
411233

412-
[acorn]: https://github.com/ternjs/acorn
234+
[acorn]: https://github.com/acornjs/acorn
413235
[babylon]: https://babeljs.io/
414236
[charlike-cli]: https://github.com/tunnckoCore/charlike-cli
415237
[charlike]: https://github.com/tunnckoCore/charlike
@@ -462,18 +284,18 @@ Project scaffolded and managed with [hela][].
462284
[prettier-url]: https://github.com/prettier/prettier
463285
[prettier-img]: https://img.shields.io/badge/styled_with-prettier-f952a5.svg
464286

465-
[nodesecurity-url]: https://nodesecurity.io/orgs/tunnckocore/projects/42a5e14a-70da-49ee-86e7-d1f39ed08603
466-
[nodesecurity-img]: https://nodesecurity.io/orgs/tunnckocore/projects/42a5e14a-70da-49ee-86e7-d1f39ed08603/badge
287+
[nodesecurity-url]: https://nodesecurity.io/orgs/tunnckocore-dev/projects/5d75a388-acfe-4668-ad18-e98564e387e1
288+
[nodesecurity-img]: https://nodesecurity.io/orgs/tunnckocore-dev/projects/5d75a388-acfe-4668-ad18-e98564e387e1/badge
467289
<!-- the original color of nsp:
468290
[nodesec-img]: https://img.shields.io/badge/nsp-no_known_vulns-35a9e0.svg -->
469291

470-
[semantic-release-url]: https://github.com/apps/new-release
471-
[semantic-release-img]: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-new--release-e10079.svg
292+
[semantic-release-url]: https://github.com/semantic-release/semantic-release
293+
[semantic-release-img]: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg
472294

473295
[ccommits-url]: https://conventionalcommits.org/
474296
[ccommits-img]: https://img.shields.io/badge/conventional_commits-1.0.0-yellow.svg
475297

476298
[nodeversion-url]: https://nodejs.org/en/download
477299
[nodeversion-img]: https://img.shields.io/node/v/parse-function.svg
478300

479-
[hela]: https://github.com/tunnckoCore/hela
301+
[hela]: https://github.com/tunnckoCore/hela

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
"start": "hela",
1414
"test": "NODE_ENV=test yarn hela test",
1515
"precommit": "yarn hela precommit",
16-
"commit": "yarn hela commit",
17-
"release": "new-release"
16+
"commit": "yarn hela commit"
1817
},
1918
"license": "MIT",
2019
"licenseStart": 2016,

0 commit comments

Comments
 (0)