Skip to content

Commit

Permalink
feat: remove compatible for sequelize (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
whxaxes committed Jun 10, 2019
1 parent 934bc46 commit 8003dc2
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 17 deletions.
9 changes: 1 addition & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,12 @@ export function getDefaultWatchDirs(opt: TsHelperOption = {}) {

// model
const eggInfo = (opt && opt.cwd) ? utils.getEggInfo(opt.cwd) : undefined;
const hasModelInCustomLoader = !!deepGet(eggInfo, 'config.customLoader.model');
const sequelizeInfo = deepGet(eggInfo, 'plugins.sequelize', {});
const isUsingSequelize = sequelizeInfo.package === 'egg-sequelize' && sequelizeInfo.enable;
baseConfig.model = {
directory: 'app/model',
generator: 'function',
interface: 'IModel',
caseStyle: 'upper',
enabled: !hasModelInCustomLoader,
...(isUsingSequelize ? {
framework: 'sequelize',
interface: 'Sequelize',
} : {}),
enabled: !deepGet(eggInfo, 'config.customLoader.model'),
};

// config
Expand Down
9 changes: 0 additions & 9 deletions test/generators/class.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import path from 'path';
import assert = require('assert');
import { GeneratorResult } from '../../dist/';
import { triggerGenerator } from './utils';
import { createNodeModuleSym } from '../utils';

describe('generators/class.test.ts', () => {
const appDir = path.resolve(__dirname, '../fixtures/app');
Expand Down Expand Up @@ -52,14 +51,6 @@ describe('generators/class.test.ts', () => {
assert(result.content!.includes('Person: ReturnType<typeof ExportPerson>;'));
});

it('should support sequelize with model', () => {
const newAppDir = path.resolve(__dirname, '../fixtures/app4');
createNodeModuleSym(newAppDir);
const result = triggerGenerator<GeneratorResult>('model', newAppDir, undefined);
assert(result.content!.includes('declare module \'sequelize\' {'));
assert(result.content!.includes('interface Sequelize'));
});

it('should support interfaceHandle with model without error', () => {
const result = triggerGenerator<GeneratorResult>('model', appDir, undefined, {
generator: 'function',
Expand Down

0 comments on commit 8003dc2

Please sign in to comment.