Skip to content

Commit

Permalink
1. added typescript badge
Browse files Browse the repository at this point in the history
2. added typescript usage notice in readme,  #19
  • Loading branch information
oe committed Nov 7, 2018
1 parent 56f5873 commit 638f67f
Show file tree
Hide file tree
Showing 5 changed files with 606 additions and 27 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"scripts": {
"dev": "npm run build:dir",
"build": "npm run lint && npm run test && npm run build:dir",
"build:dir": "npm run clean:builddir && rollup -c --environment format:cjs && rollup -c --environment format:es",
"build:dir": "npm run clean:builddir && rollup -c rollup.config.ts",
"clean:builddir": "rimraf dist/*",
"postpublish": "./post-publish2npm.sh",
"test": "jest --coverage",
Expand Down
7 changes: 7 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
<a href="https://travis-ci.org/evecalm/truncate-html">
<img src="https://travis-ci.org/evecalm/truncate-html.svg?branch=master" alt="Travis CI">
</a>
<a href="#readme">
<img src="https://badges.frapsoft.com/typescript/code/typescript.svg?v=101" alt="code with typescript" height="20">
</a>
<a href="#readme">
<img src="https://badge.fury.io/js/truncate-html.svg" alt="npm version" height="18">
</a>
Expand Down Expand Up @@ -108,6 +111,10 @@ truncate($)

## Notice

### Typescript support

This lib is written with typescript and has a defination file along with it. You may need to update your `tsconfig.json` by adding `"esModuleInterop": true` to the `compilerOptions` if you encounter some typing errors, see #19.

### About final string length

If the html string content's length is shorter than `options.length`, then no ellipsis will be appended to the final html string. If longer, then the final string length will be `options.length` + `options.ellipsis`. And if you set `reserveLastWord` to true of none zero number, the final string will be various.
Expand Down
26 changes: 0 additions & 26 deletions rollup.config.js

This file was deleted.

34 changes: 34 additions & 0 deletions rollup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import buble from 'rollup-plugin-buble'
import typescript from 'rollup-plugin-typescript2'

const pkg = require('./package.json')

function getConfig (type) {
return {
input: 'src/truncate.ts',
output: {
name: 'truncate-html',
banner: `/*!
* trancate-html v${pkg.version}
* Copyright© ${new Date().getFullYear()} Saiya ${pkg.homepage}
*/`,
format: type,
file: `dist/truncate.${type}.js`
},
plugins: [
typescript({
tsconfigOverride: {
compilerOptions: { module: 'esnext' }
},
typescript: require('typescript')
}),
buble()
],
external: ['cheerio']
}
}

export default [
getConfig('cjs'),
getConfig('es')
]
Loading

0 comments on commit 638f67f

Please sign in to comment.