-
Notifications
You must be signed in to change notification settings - Fork 509
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
974805c
commit 89c0470
Showing
13 changed files
with
293 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
version: 2 | ||
|
||
defaults: &defaults | ||
working_directory: ~/repo | ||
docker: | ||
- image: circleci/node | ||
|
||
jobs: | ||
test: | ||
<<: *defaults | ||
steps: | ||
- checkout | ||
- restore_cache: | ||
keys: | ||
- v1-dependencies-{{ checksum "yarn.lock" }} | ||
# fallback to using the latest cache if no exact match is found | ||
- v1-dependencies- | ||
|
||
- run: | ||
name: Install and build package | ||
command: yarn install --frozen-lockfile | ||
|
||
- run: | ||
name: Run tests | ||
command: yarn test --runInBand --no-cache --coverage | ||
|
||
- save_cache: | ||
paths: | ||
- node_modules | ||
key: v1-dependencies-{{ checksum "yarn.lock" }} | ||
|
||
- persist_to_workspace: | ||
root: ~/repo | ||
paths: . | ||
|
||
workflows: | ||
version: 2 | ||
test-deploy: | ||
jobs: | ||
- test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"scripts": { | ||
"build": "tsdx build" | ||
}, | ||
"name": "build-default", | ||
"license": "MIT" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export const sum = (a: number, b: number) => { | ||
if ('development' === process.env.NODE_ENV) { | ||
console.log('fuck'); | ||
} | ||
return a + b; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { sum } from '../src'; | ||
|
||
describe('fuck', () => { | ||
it('works', () => { | ||
expect(sum(1, 1)).toEqual(2); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es5", | ||
"module": "ESNext", | ||
"lib": ["dom", "esnext"], | ||
"declaration": true, | ||
"sourceMap": true, | ||
"rootDir": "./", | ||
"strict": true, | ||
"noImplicitAny": true, | ||
"strictNullChecks": true, | ||
"strictFunctionTypes": true, | ||
"strictPropertyInitialization": true, | ||
"noImplicitThis": true, | ||
"alwaysStrict": true, | ||
"noUnusedLocals": true, | ||
"noUnusedParameters": true, | ||
"noImplicitReturns": true, | ||
"noFallthroughCasesInSwitch": true, | ||
"moduleResolution": "node", | ||
"baseUrl": "./", | ||
"paths": { | ||
"*": ["src/*", "node_modules/*"] | ||
}, | ||
"jsx": "react", | ||
"esModuleInterop": true | ||
}, | ||
"include": ["src", "types"], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
'use strict'; | ||
|
||
const shell = require('shelljs'); | ||
const path = require('path'); | ||
const rootDir = process.cwd(); | ||
|
||
shell.config.silent = true; | ||
|
||
module.exports = { | ||
setupStageWithFixture: (stageName, fixtureName) => { | ||
const stagePath = path.join(rootDir, stageName); | ||
shell.mkdir(stagePath); | ||
shell.exec(`cp -a ${rootDir}/test/fixtures/${fixtureName}/. ${stagePath}/`); | ||
shell.ln( | ||
'-s', | ||
path.join(rootDir, 'node_modules'), | ||
path.join(stagePath, 'node_modules') | ||
); | ||
shell.cd(stagePath); | ||
}, | ||
|
||
teardownStage: stageName => { | ||
shell.cd(rootDir); | ||
shell.rm('-rf', path.join(rootDir, stageName)); | ||
}, | ||
|
||
rootDir, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"roots": ["<rootDir>/tests"], | ||
"collectCoverageFrom": ["**/*.js"], | ||
"testMatch": [ | ||
"<rootDir>/tests/**/?(*.)(spec|test).(ts|js)?(x)" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* @jest-environment node | ||
*/ | ||
'use strict'; | ||
|
||
const shell = require('shelljs'); | ||
const util = require('../fixtures/util'); | ||
|
||
shell.config.silent = false; | ||
|
||
const stageName = 'stage-build'; | ||
|
||
describe('tsdx build', () => { | ||
beforeAll(() => { | ||
util.teardownStage(stageName); | ||
}); | ||
|
||
it('should compile files into a dist directory', () => { | ||
util.setupStageWithFixture(stageName, 'build-default'); | ||
|
||
const output = shell.exec('node ../dist/index.js build'); | ||
|
||
expect(shell.test('-f', 'dist/index.js')).toBeTruthy(); | ||
expect( | ||
shell.test('-f', 'dist/build-default.cjs.development.js') | ||
).toBeTruthy(); | ||
expect( | ||
shell.test('-f', 'dist/build-default.cjs.production.js') | ||
).toBeTruthy(); | ||
expect( | ||
shell.test('-f', 'dist/build-default.es.production.js') | ||
).toBeTruthy(); | ||
expect( | ||
shell.test('-f', 'dist/build-default.umd.development.js') | ||
).toBeTruthy(); | ||
expect( | ||
shell.test('-f', 'dist/build-default.umd.development.js') | ||
).toBeTruthy(); | ||
|
||
expect(shell.test('-f', 'dist/index.d.ts')).toBeTruthy(); | ||
|
||
expect(output.code).toBe(0); | ||
}); | ||
|
||
afterEach(() => { | ||
util.teardownStage(stageName); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'use strict'; | ||
|
||
const psTree = require('ps-tree'); | ||
|
||
// Loops through processes and kills them | ||
module.exports = (pid, signal = 'SIGKILL', callback) => { | ||
psTree(pid, (err, children) => { | ||
let arr = [pid].concat(children.map(p => p.PID)); | ||
arr = arr.filter((item, poss) => arr.indexOf(item) === poss); | ||
arr.forEach(tpid => { | ||
try { | ||
process.kill(tpid, signal); | ||
} catch (ex) { | ||
const logger = console; | ||
logger.log('Could not kill process', tpid, ex); | ||
} | ||
}); | ||
if (callback) { | ||
callback(); | ||
} | ||
}); | ||
}; |
Oops, something went wrong.