diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..bbb9fea --- /dev/null +++ b/.babelrc @@ -0,0 +1,7 @@ +{ + "presets": ["env"], + "plugins": [ + "babel-plugin-add-module-exports", + "transform-es2015-modules-umd" + ] +} diff --git a/.gitignore b/.gitignore index b509c88..65e745b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ coverage/ node_modules/ +.nyc_output/ \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 30b1854..b58c1c4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,5 +13,7 @@ before_script: - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter - chmod +x ./cc-test-reporter - ./cc-test-reporter before-build +script: + - nyc --reporter=lcov npm test after_script: - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT diff --git a/dist/smallstache.min.js b/dist/smallstache.min.js index 8c7c011..3845e01 100644 --- a/dist/smallstache.min.js +++ b/dist/smallstache.min.js @@ -1,2 +1,2 @@ -!function(e,t){if("function"==typeof define&&define.amd)define(["module","exports"],t);else if("undefined"!=typeof exports)t(module,exports);else{var o={exports:{}};t(o,o.exports),e.Smallstache=o.exports}}(this,function(e,t){"use strict";function o(e){if("string"!=typeof e)throw new TypeError("Template source must be a string");this.source=e}Object.defineProperty(t,"__esModule",{value:!0}),o.prototype.fill=function(e){function t(t,o){return null!=e[o]?e[o]:t}return this.source.replace(/{{\s*([^}\s]+)\s*}}/g,t)},t.default=o,e.exports=t.default}); -//# sourceMappingURL=./smallstache.js.map +!function(e,t){if("function"==typeof define&&define.amd)define(["module","exports"],t);else if("undefined"!=typeof exports)t(module,exports);else{var o={exports:{}};t(o,o.exports),e.Smallstache=o.exports}}(this,function(e,t){"use strict";function o(e){if("string"!=typeof e)throw new TypeError("Template source must be a string");this.source=e}Object.defineProperty(t,"__esModule",{value:!0}),o.prototype.fill=function(o){return this.source.replace(/{{\s*([^}\s]+)\s*}}/g,function(e,t){return null!=o[t]?o[t]:e})},t.default=o,e.exports=t.default}); +//# sourceMappingURL=./smallstache.js.map \ No newline at end of file diff --git a/package.json b/package.json index 90a7a54..b2fa78b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "smallstache", - "version": "0.4.5", + "version": "0.4.6", "description": "Lightweight template engine similar to Mustache/Handlebars.", "keywords": [ "smallstache", @@ -11,21 +11,22 @@ "main": "dist/smallstache.js", "scripts": { "build": "npm run bundle && npm run compress", - "bundle": "mkdirp ./dist && babel --plugins babel-plugin-add-module-exports,transform-es2015-modules-umd ./src/Smallstache.js > ./dist/smallstache.js", - "compress": "cd ./dist && uglifyjs --compress --mangle --source-map=./smallstache.js.map -- ./smallstache.js > ./smallstache.min.js && cd ../", - "pretest": "mkdirp ./spec/src && node ./tools/test_loading_helper.js", - "test": "istanbul cover '-x ./spec/*.Spec.js' jasmine JASMINE_CONFIG_PATH=spec/jasmine.json", - "posttest": "rimraf ./spec/src" + "bundle": "mkdirp ./dist && babel ./src/Smallstache.js > ./dist/smallstache.js", + "compress": "cd ./dist && uglifyjs ./smallstache.js --compress --mangle --output smallstache.min.js --source-map \"filename='./smallstache.js.map',url='./smallstache.js.map'\" && cd ../", + "test": "jest --coverage" }, "devDependencies": { - "babel-cli": "6.16.x", + "babel-cli": "6.26.x", + "babel-core": "6.26.x", + "babel-jest": "23.0.x", "babel-plugin-add-module-exports": "0.2.x", - "babel-plugin-transform-es2015-modules-umd": "6.12.x", - "istanbul": "0.4.x", - "jasmine": "2.5.x", + "babel-plugin-transform-es2015-modules-umd": "6.24.x", + "babel-preset-env": "1.7.x", + "jest": "23.1.x", "mkdirp": "0.5.x", - "rimraf": "2.5.x", - "uglify-js": "2.7.x" + "nyc": "12.0.x", + "regenerator-runtime": "0.11.x", + "uglify-js": "3.4.x" }, "files": [ "dist" diff --git a/spec/jasmine.json b/spec/jasmine.json deleted file mode 100644 index 370fc44..0000000 --- a/spec/jasmine.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "spec_dir": "spec", - "spec_files": [ - "**/*[sS]pec.js" - ], - "helpers": [ - "helpers/**/*.js" - ], - "stopSpecOnExpectationFailure": false, - "random": true -} diff --git a/spec/Smallstache.Spec.js b/tests/Smallstache.spec.js similarity index 98% rename from spec/Smallstache.Spec.js rename to tests/Smallstache.spec.js index d972383..bdfb14a 100644 --- a/spec/Smallstache.Spec.js +++ b/tests/Smallstache.spec.js @@ -1,4 +1,4 @@ -var Smallstache = require('./src/smallstache.js'); +import Smallstache from '../src/Smallstache'; describe('A Smallstache', function() { it('should take string source', function() { diff --git a/tools/test_loading_helper.js b/tools/test_loading_helper.js deleted file mode 100644 index ba1de97..0000000 --- a/tools/test_loading_helper.js +++ /dev/null @@ -1,17 +0,0 @@ -/* - Converts native module export to CommonJS export for tests. -*/ - -var fs = require('fs'); - -var sourceFile = './src/Smallstache.js'; -var testedFile = './spec/src/smallstache.js'; - -var nativeExport = 'export { Smallstache as default };'; -var nodeExport = 'module.exports = Smallstache;'; - -fs.readFile(sourceFile, 'utf-8', function(err, source) { - source = source.replace(nativeExport, nodeExport); - - fs.writeFile(testedFile, source); -});