Skip to content

Commit

Permalink
feat: support knex 0.16 (#940)
Browse files Browse the repository at this point in the history
  • Loading branch information
kjin committed Dec 17, 2018
1 parent 96863e7 commit 0b404a1
Show file tree
Hide file tree
Showing 7 changed files with 212 additions and 211 deletions.
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -54,6 +54,7 @@
"@types/extend": "^3.0.0",
"@types/glob": "^7.0.0",
"@types/is": "0.0.21",
"@types/knex": "^0.15.1",
"@types/methods": "^1.1.0",
"@types/mocha": "^5.2.5",
"@types/ncp": "^2.0.1",
Expand Down
10 changes: 8 additions & 2 deletions scripts/init-test-fixtures.ts
@@ -1,5 +1,5 @@
import * as path from 'path';
import { BUILD_DIRECTORY, globP, statP, ncpP, spawnP, readFileP, writeFileP, mkdirP } from './utils';
import { BUILD_DIRECTORY, statP, ncpP, spawnP, readFileP, writeFileP, mkdirP } from './utils';
import { readdir } from 'fs';
import * as pify from 'pify';
import * as semver from 'semver';
Expand All @@ -8,7 +8,7 @@ const readdirP: (path: string) => Promise<string[]> = pify(readdir);

export async function initTestFixtures(installPlugins: boolean) {
// Copy fixtures to build directory
const fixtureDirectories = await globP('./test/**/fixtures');
const fixtureDirectories = ['./test/fixtures'];
await Promise.all(fixtureDirectories.map(async (fixtureDirectory) => {
const newLocation = `${BUILD_DIRECTORY}/${path.relative('.', fixtureDirectory)}`;
await ncpP(fixtureDirectory, newLocation);
Expand All @@ -20,6 +20,12 @@ export async function initTestFixtures(installPlugins: boolean) {

// Run `npm install` for package fixtures
const packageFixtures = JSON.parse(await readFileP('./test/fixtures/plugin-fixtures.json', 'utf8') as string);
await mkdirP('./build/test/plugins/fixtures').catch((e: { code?: string }) => {
// it's OK if this directory already exists
if (e.code !== 'EEXIST') {
throw e;
}
});
for (const packageName in packageFixtures) {
const packageDirectory = `./build/test/plugins/fixtures/${packageName}`;
let fixtureExists = true;
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/plugin-knex.ts
Expand Up @@ -55,8 +55,8 @@ module.exports = [
unpatch: unpatchClient
},
{
// knex 0.10.x and 0.11.x do not need patching
versions: '>=0.10 <=0.11'
// these knex versions do not need patching
versions: '>=0.10 <=0.11 || >=0.14 <=0.16'
}
];

Expand Down
14 changes: 14 additions & 0 deletions test/fixtures/plugin-fixtures.json
Expand Up @@ -95,6 +95,20 @@
},
"_mainModule": "knex"
},
"knex0.14": {
"dependencies": {
"knex": "^0.14.0",
"mysql": "^2.13.0"
},
"_mainModule": "knex"
},
"knex0.16": {
"dependencies": {
"knex": "^0.16.0",
"mysql": "^2.13.0"
},
"_mainModule": "knex"
},
"koa1": {
"dependencies": {
"koa": "^1.1.2"
Expand Down

0 comments on commit 0b404a1

Please sign in to comment.