-
Notifications
You must be signed in to change notification settings - Fork 132
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
hirsch
committed
Jun 4, 2019
1 parent
f1bbdbf
commit 84df811
Showing
13 changed files
with
119 additions
and
168 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
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
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 |
---|---|---|
@@ -1,36 +1,10 @@ | ||
import { loadFiles, importFiles } from './utils/file.util' | ||
import { SeederConstructor } from './types' | ||
|
||
// ------------------------------------------------------------------------- | ||
// Util functions | ||
// ------------------------------------------------------------------------- | ||
|
||
const loadFactoryFiles = loadFiles('**/*actory{.js,.ts}') | ||
const loadSeedFiles = loadFiles('**/*{.js,.ts}') | ||
|
||
// ------------------------------------------------------------------------- | ||
// Facade functions | ||
// ------------------------------------------------------------------------- | ||
|
||
export const loadEntityFactories = (pathToFolder: string): Promise<string[]> => { | ||
return new Promise((resolve, reject) => { | ||
loadFactoryFiles(pathToFolder)(files => { | ||
importFiles(files) | ||
resolve(files) | ||
})(reject) | ||
}) | ||
} | ||
|
||
export const loadSeeds = (pathToFolder: string): Promise<string[]> => { | ||
return new Promise((resolve, reject) => { | ||
loadSeedFiles(pathToFolder + '/')(resolve)(reject) | ||
}) | ||
} | ||
|
||
export const importSeed = (filePath: string): any => { | ||
export const importSeed = (filePath: string): SeederConstructor => { | ||
let className = filePath.split('/')[filePath.split('/').length - 1] | ||
className = className.replace('.ts', '').replace('.js', '') | ||
className = className.split('-')[className.split('-').length - 1] | ||
|
||
// TODO: without the default | ||
const seedFileObject: any = require(filePath) | ||
return seedFileObject.default | ||
} |
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
Oops, something went wrong.