From ef7bc7a49b10b045093c6798c7d3bbd122d5d76f Mon Sep 17 00:00:00 2001 From: Yosuke Furukawa Date: Mon, 15 Dec 2014 19:16:55 +0900 Subject: [PATCH] Add filter for source is es5 --- demo/person.js | 20 ++++++++++++++++++++ index.js | 5 ++++- test/person_test.js | 15 +++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 demo/person.js create mode 100644 test/person_test.js diff --git a/demo/person.js b/demo/person.js new file mode 100644 index 0000000..343ba64 --- /dev/null +++ b/demo/person.js @@ -0,0 +1,20 @@ +/* no transpile, this is */ +(function(global){ + "use strict"; + var Person = function(name, age){ + this.name = name; + this.age = age; + }; + Person.prototype.getAge = function() { + return this.age; + }; + Person.prototype.greet = function() { + return "Hello! I am " + this.name + ". My age is " + this.age; + } + if (module && module.exports) { + module.exports = Person; + } else { + global.Person = Person; + } +}(typeof global !== 'undefined' ? global : this)); + diff --git a/index.js b/index.js index 56f624f..a2ec625 100644 --- a/index.js +++ b/index.js @@ -32,7 +32,10 @@ function espowerTraceur (options) { }; traceur.require.makeDefault(function (filename) { // Don't compile our dependencies. - return filename.indexOf('node_modules') === -1; + if (filename.indexOf('node_modules') !== -1) return false; + // Don't compile files not included our test dirs. + if (!minimatch(filename, pattern)) return false; + return true; }); } diff --git a/test/person_test.js b/test/person_test.js new file mode 100644 index 0000000..bf99a23 --- /dev/null +++ b/test/person_test.js @@ -0,0 +1,15 @@ +let assert = require("power-assert") +let Person = require("../demo/person") + +describe("Person", ()=>{ + let name = "Alice" + let age = 4 + let alice = new Person(name, age) + it("alice get age", ()=>{ + assert.equal(alice.getAge(), age) + }) + it("alice greet", ()=>{ + assert.equal(alice.greet(), `Hello! I am ${name}. My age is ${age}`) + }) +}) +