Skip to content

Commit

Permalink
Merge pull request #2 from MitMaro/travis-ci
Browse files Browse the repository at this point in the history
Setup Travis CI
  • Loading branch information
MitMaro authored Nov 11, 2018
2 parents 12094cc + 3f20bed commit 4f0dd99
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 10 deletions.
12 changes: 6 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.nyc_output/
/.nyc_output/
node_modules/
build/
coverage/
lib/
types/
test/fixtures/access-denied.tpl
/build/
/coverage/
/lib/
/types/
/test/fixtures/access-denied.tpl
38 changes: 38 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
sudo: false
notifications:
email:
on_success: never
on_failure: always
language: node_js
branches:
only:
- master
- /^v\d+\.\d+\.\d+$/
stages:
- test
- deploy
jobs:
include:
- stage: test
node_js: 10
script: ./scripts/test.bash :unit
- stage: test
node_js: 8
before_script: npm install coveralls
script:
- ./scripts/test.bash :coverage
- ./scripts/lint.bash
after_script: nyc report --reporter=text-lcov | coveralls
- stage: deploy
node_js: 8
skip_cleanup: true
script: ./scripts/build.bash
deploy:
provider: npm
email: mitmaro@gmail.com
skip_cleanup: true
api_key:
secure: "CMpOGrptULWS3VnGi8slkp6Wf3FlSVJRfsvJmQgOExF+sq19yctF33jXg0cfRPbjDZSxVzdq0PR4py+6AspMTuo0AQVT4XhKOIYARPE8POsUPv0z88Ik8r5tKhbIDiwvdvhxPqBV1iI1jWK9rMNduOibSCJpEr3F4jd/yajsUjePvj3kO11ic6JtyjIqIQ9Et6bHtMbD0Hnhd+na8wGKdVJYWx6CSGtHB1dNK8gKwDyfZa/itlGSBFGBno1K2yI9LoOAAHilt/bMGwZ2EjjljQEhdqAUUn7xMUVPt30EPt0K8rzcLoUOZGCwmEG8sa0Rk9VDS6pmHQFu9WTxIquLfiVkLnB4KQd7OdxIh0z9BM+2Ho+wZSXulgHoRkkEa3VvwEee5le6IbayAbBLkDt0o8g+qHmvC2nMDkUxxwmjlLjJtaI3pi+UyYyI9sCRcDHfTyZlJ4N4rjnN9piWGeL/9i+Oo977hNDwTFjlVUfY5B9fQ7uJ6mhaLJKVsFVDfnq2g5Y5ENJ5WXCQKPPyATvN2EKxbHqNYdDMDancA+hVT7CmDI13fGT+YDLMvoLp4Yjh6D7ziVb2SSnKTnJhulpeNZ/B+h7VQX/STD0D5JrbAMicplNkbN6Ej5X1lZQUAZ8c8uPocAgZKx0cYVk98XBC67C7OOhnLt+LOZaBfz02yCY="
on:
tags: true
repo: MitMaro/node-sql-template-engine
23 changes: 19 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
{
"name": "sql-templates",
"version": "0.0.1",
"name": "@mitmaro/sql-template-engine",
"version": "0.1.0",
"description": "A SQL template engine",
"main": "src/index.js",
"main": "lib/index.js",
"files": [
"lib",
"types"
],
"directories": {
"test": "test"
},
"types": "types/index.d.ts",
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git@github.com:MitMaro/node-sql-template-engine.git"
},
"engines": {
"node": ">= 8"
},
"scripts": {
"build": "scripts/build.bash",
"build:docs": "scripts/docs.bash",
Expand All @@ -14,7 +29,7 @@
"test:unit": "scripts/test.bash :unit",
"test:coverage": "scripts/test.bash :coverage"
},
"author": "Tim Oram <mitmaro@gmail.com>",
"author": "Tim Oram <dev@mitmaro.ca>",
"license": "ISC",
"devDependencies": {
"@mitmaro/build-scripts": "^0.1.5",
Expand Down
25 changes: 25 additions & 0 deletions src/lib/memory-cache.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import {AbstractSyntaxTree} from '../abstract-syntax-tree';
import {AbstractSyntaxTreeCache} from '../abstract-syntax-tree-cache';

/**
* Create an in-memory cache for the compiled templates
* @returns A cache instance
*/
export function createMemoryCache(): AbstractSyntaxTreeCache {
const cache = new Map<string, AbstractSyntaxTree>();

return {
/**
* Get or create a value for the key
* @param key The key of this entry
* @param factory A function to call to create the value if it is missing
* @returns Resolves with the compiled template as an abstract syntax tree
*/
async entry(key: string, factory: () => Promise<AbstractSyntaxTree>): Promise<AbstractSyntaxTree> {
if (!cache.has(key)) {
cache.set(key, await factory());
}
return cache.get(key)!;
},
};
}

0 comments on commit 4f0dd99

Please sign in to comment.