diff --git a/.babelrc b/.babelrc index 97e6119..2196c13 100644 --- a/.babelrc +++ b/.babelrc @@ -2,6 +2,6 @@ "presets": [ "es2015", "es2016", - "es2017" + "es2017" ] } diff --git a/README.md b/README.md index a46803d..d4ce846 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,8 @@ [stability-index]: https://nodejs.org/api/documentation.html#documentation_stability_index [npm-image]: https://img.shields.io/npm/v/endent.svg?style=flat-square [npm-url]: https://www.npmjs.com/package/endent -[travis-image]: https://img.shields.io/travis/ZhouHansen/endent.svg?style=flat-square -[travis-url]: https://travis-ci.org/ZhouHansen/endent +[travis-image]: https://img.shields.io/travis/indentjs/endent.svg?style=flat-square +[travis-url]: https://travis-ci.org/indentjs/endent [dm-image]: http://img.shields.io/npm/dm/endent.svg?style=flat-square An ES6 string tag that endows some indentation. Recommnend use it with [dedent](https://github.com/dmnd/dedent)! May help you generate pretty javascript template with dynamic json. diff --git a/__tests__/endent-tests.js b/__tests__/endent-tests.js index cef44dc..40442dd 100644 --- a/__tests__/endent-tests.js +++ b/__tests__/endent-tests.js @@ -1,4 +1,4 @@ -import endent from '../' +import endent from '../endent.js' import dedent from 'dedent' describe('endent', () => { @@ -14,13 +14,14 @@ describe('endent', () => { } var colors = ['red', 'pink', 'white'] + var objectName = "someobj" var jsFile = dedent(endent` module.exports = store function store (state, emitter) { emitter.on("DOMContentLoaded", function () { - state["someobj"] = ${endent.pretty(someobj)} + state[${objectName}] = ${endent.pretty(someobj)} state["colors"] = ${endent.pretty(colors)} state["name"] = ${endent.pretty("jack")} state["number"] = ${endent.pretty(123)} diff --git a/dist/index.js b/dist/endent.js similarity index 97% rename from dist/index.js rename to dist/endent.js index 42ffc5b..30dc8c2 100644 --- a/dist/index.js +++ b/dist/endent.js @@ -31,7 +31,7 @@ function endent(strings) { if (i < values.length) { if (values[i] && values[i][ENDENT_ID]) { - var rawlines = raw[i].split('\n'); + var rawlines = result.split('\n'); var l = rawlines[rawlines.length - 1].search(/\S/); var endentation = ' '.repeat(l); var valueLines = values[i][ENDENT_ID].split('\n'); diff --git a/index.js b/endent.js similarity index 95% rename from index.js rename to endent.js index 685eeec..c4f8bd9 100644 --- a/index.js +++ b/endent.js @@ -14,7 +14,7 @@ function endent (strings, ...values) { if (i < values.length) { if (values[i] && values[i][ENDENT_ID]) { - var rawlines = raw[i].split('\n') + var rawlines = result.split('\n') var l = rawlines[rawlines.length - 1].search(/\S/) var endentation = ' '.repeat(l) var valueLines = values[i][ENDENT_ID].split('\n') diff --git a/package.json b/package.json index 32dff98..20aea17 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,13 @@ { "name": "endent", - "version": "1.0.0", + "version": "1.0.5", "description": "➡️ ES6 string tag that endows indentation from multi-line strings", - "main": "dist/index.js", + "main": "dist/endent.js", "files": [ - "dist/index.js" + "dist/endent.js" ], "scripts": { - "build": "babel index.js --out-file dist/index.js", + "build": "babel endent.js --out-file dist/endent.js", "test": "jest" }, "repository": { @@ -27,7 +27,6 @@ "license": "ISC", "devDependencies": { "babel-cli": "^6.22.2", - "babel-plugin-transform-flow-strip-types": "^6.22.0", "babel-preset-es2015": "^6.22.0", "babel-preset-es2016": "^6.22.0", "babel-preset-es2017": "^6.22.0",