@fullstackio/cq
Advanced tools
Comparing version 2.0.1 to 2.0.2
@@ -129,2 +129,10 @@ 'use strict'; | ||
} | ||
}, | ||
Constructor: function Constructor(node) { | ||
// `constructor` is a special node in TypeScript (vs. babylon where | ||
// it's an Identifier) If the query is looking for a constructor by | ||
// identifier, then we will accept this Constructor node | ||
if ('constructor' === query.matcher && 'IDENTIFIER' === query.type) { | ||
paths = [].concat(_toConsumableArray(paths), [node]); | ||
} | ||
} | ||
@@ -131,0 +139,0 @@ }); |
{ | ||
"name": "@fullstackio/cq", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "query code with selectors", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -103,2 +103,10 @@ /** | ||
} | ||
}, | ||
Constructor: function (node) { | ||
// `constructor` is a special node in TypeScript (vs. babylon where | ||
// it's an Identifier) If the query is looking for a constructor by | ||
// identifier, then we will accept this Constructor node | ||
if('constructor' === query.matcher && 'IDENTIFIER' === query.type) { | ||
paths = [...paths, node]; | ||
} | ||
} | ||
@@ -105,0 +113,0 @@ }); |
@@ -301,2 +301,8 @@ import 'babel-polyfill'; | ||
it('should get a constructor', () => { | ||
let { code } = cq(es6Class, '.constructor'); | ||
const wanted = lines(es6Class, 8, 11); | ||
assert.equal(code, wanted); | ||
}); | ||
}); | ||
@@ -303,0 +309,0 @@ |
@@ -396,2 +396,25 @@ import 'babel-polyfill' | ||
describe('special identifiers', () => { | ||
const src = ` | ||
/* | ||
* A Barn is where you keep animals | ||
*/ | ||
class Barn { | ||
color: string; | ||
constructor() { | ||
color = 'red'; | ||
} | ||
} | ||
`; | ||
it('should get a constructor', () => { | ||
let { code } = cq(src, ".Barn .constructor", {engine: 'typescript'}); | ||
const wanted = lines(src, 7, 9); | ||
assert.equal(code, wanted); | ||
}) | ||
}); | ||
}); |
688369
4590