Comparing version 0.21.3 to 0.21.4
# Master (Unreleased) | ||
# 0.21.4 - 10 August, 2020 | ||
### New features: | ||
- CLI: Add new option for seed: recursive #3974 | ||
### Bug fixes: | ||
- CLI: Do not load seeds from subfolders recursively by default #3974 | ||
# 0.21.3 - 08 August, 2020 | ||
@@ -7,3 +17,3 @@ | ||
- Support multiple directories for seeds #3967 | ||
- CLI: Support multiple directories for seeds #3967 | ||
@@ -15,3 +25,3 @@ ### Bug fixes: | ||
- Fix ESM module interop for calling module/package of type 'module' #3938 | ||
- Fix migration source name in rollback all #3956 | ||
- CLI: Fix migration source name in rollback all #3956 | ||
- Fix getMergedConfig calls to include client logger #3920 | ||
@@ -18,0 +28,0 @@ - Escape single quoted values passed to defaultTo function #3899 |
@@ -8,6 +8,3 @@ // Seeder | ||
const includes = require('lodash/includes'); | ||
const { | ||
ensureDirectoryExists, | ||
getFilepathsInFolderRecursively, | ||
} = require('../util/fs'); | ||
const { ensureDirectoryExists, getFilepathsInFolder } = require('../util/fs'); | ||
const { writeJsFileUsingTemplate } = require('../util/template'); | ||
@@ -53,6 +50,8 @@ | ||
this.config = this.setConfig(config); | ||
const loadExtensions = this.config.loadExtensions; | ||
const { loadExtensions, recursive } = this.config; | ||
const seeds = flatten( | ||
await Promise.all( | ||
this._absoluteConfigDirs().map(getFilepathsInFolderRecursively) | ||
this._absoluteConfigDirs().map((d) => | ||
getFilepathsInFolder(d, recursive) | ||
) | ||
) | ||
@@ -186,2 +185,3 @@ ); | ||
sortDirsSeparately: false, | ||
recursive: false, | ||
}, | ||
@@ -188,0 +188,0 @@ this.config || {}, |
@@ -35,12 +35,16 @@ const fs = require('fs'); | ||
/** | ||
* Read recursively a directory, | ||
* sorting folders and files by alphabetically order | ||
* Read a directory, | ||
* sorting folders and files by alphabetically order. | ||
* Can be browsed recursively. | ||
* | ||
* @param {string} dir | ||
* The directory to recursively analyse | ||
* The directory to analyse | ||
* | ||
* @param {boolean} recursive | ||
* Browse directory recursively | ||
* | ||
* @returns {Promise<[string]>} | ||
* All recursively found files, concatenated to the current dir | ||
* All found files, concatenated to the current dir | ||
*/ | ||
async function getFilepathsInFolderRecursively(dir) { | ||
async function getFilepathsInFolder(dir, recursive = false) { | ||
const results = []; | ||
@@ -53,5 +57,6 @@ const pathsList = await readdir(dir); | ||
if (statFile && statFile.isDirectory()) { | ||
// Add directory to array [comment if you need to remove the directories from the array] | ||
const subFiles = await getFilepathsInFolderRecursively(currentFile); | ||
results.push(...subFiles); | ||
if (recursive) { | ||
const subFiles = await getFilepathsInFolder(currentFile, true); | ||
results.push(...subFiles); | ||
} | ||
} else { | ||
@@ -72,3 +77,3 @@ results.push(currentFile); | ||
ensureDirectoryExists, | ||
getFilepathsInFolderRecursively, | ||
getFilepathsInFolder, | ||
}; |
{ | ||
"name": "knex", | ||
"version": "0.21.3", | ||
"version": "0.21.4", | ||
"description": "A batteries-included SQL query & schema builder for Postgres, MySQL and SQLite3 and the Browser", | ||
@@ -5,0 +5,0 @@ "main": "knex.js", |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
586906
15351