fix: collection importer has incorrect reference (#1495)
* fix: collection importer has incorrect reference * test: reimport test
This commit is contained in:
parent
1bf0e0ac72
commit
c9572fc9f6
@ -7,7 +7,19 @@ describe('collection importer', () => {
|
||||
const reader = new ImporterReader(path.resolve(__dirname, './fixtures/collections'));
|
||||
|
||||
const modules = await reader.read();
|
||||
expect(modules).toBeDefined();
|
||||
|
||||
const posts = modules.find((m) => m.name === 'posts');
|
||||
|
||||
expect(posts).toMatchObject({
|
||||
name: 'posts',
|
||||
fields: [{ type: 'string', name: 'title' }],
|
||||
});
|
||||
|
||||
posts.schema = 'test';
|
||||
|
||||
const modules2 = await reader.read();
|
||||
const posts2 = modules2.find((m) => m.name === 'posts');
|
||||
expect(posts2.schema).toBeFalsy();
|
||||
});
|
||||
|
||||
test('extend', async () => {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import path from 'path';
|
||||
import { readdir } from 'fs/promises';
|
||||
import { isPlainObject } from 'lodash';
|
||||
import { cloneDeep, isPlainObject } from 'lodash';
|
||||
import { requireModule } from '@nocobase/utils';
|
||||
|
||||
export type ImportFileExtension = 'js' | 'ts' | 'json';
|
||||
@ -36,6 +36,6 @@ export class ImporterReader {
|
||||
return typeof mod === 'function' ? mod() : mod;
|
||||
});
|
||||
|
||||
return (await Promise.all(modules)).filter((module) => isPlainObject(module));
|
||||
return (await Promise.all(modules)).filter((module) => isPlainObject(module)).map((module) => cloneDeep(module));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user