@tryghost/mg-fs-utils 0.12.3 → 0.12.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/csv.js +11 -8
  2. package/package.json +2 -2
package/lib/csv.js CHANGED
@@ -99,18 +99,21 @@ const writeCSV = async (data, filePath, fileName) => {
99
99
 
100
100
  /**
101
101
  * Check if a CSV has the required keys
102
- * @param {string} filePath Path to CSV file
103
- * @param {array} theKeys Array of keys the CSV must include
102
+ * @param {object} data
103
+ * @param {string} data.filePath Path to CSV file
104
+ * @param {array} data.required Array of keys the CSV must include
105
+ * @param {array} data.blocked Array of keys the CSV must include
104
106
  * @returns {boolean}
105
107
  */
106
- const hasKeys = async (filePath, theKeys = []) => {
107
- let parsed = await parseCSV(filePath);
108
- let firstRow = parsed[0];
109
- let colKeys = Object.keys(firstRow);
108
+ const hasKeys = async ({filePath, required = [], blocked = []}) => {
109
+ const parsed = await parseCSV(filePath);
110
+ const firstRow = parsed[0];
111
+ const colKeys = Object.keys(firstRow);
110
112
 
111
- let hasRequiredKeys = theKeys.every(v => colKeys.includes(v));
113
+ const hasRequiredKeys = required.every(v => colKeys.includes(v));
114
+ const hasBlockedKeys = colKeys.some(r => blocked.includes(r));
112
115
 
113
- return hasRequiredKeys;
116
+ return hasRequiredKeys && !hasBlockedKeys;
114
117
  };
115
118
 
116
119
  export default {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryghost/mg-fs-utils",
3
- "version": "0.12.3",
3
+ "version": "0.12.4",
4
4
  "repository": "https://github.com/TryGhost/migrate/tree/main/packages/mg-fs-utils",
5
5
  "author": "Ghost Foundation",
6
6
  "license": "MIT",
@@ -37,5 +37,5 @@
37
37
  "sharp": "0.31.3",
38
38
  "transliteration": "2.3.5"
39
39
  },
40
- "gitHead": "3dcab8e838ec029cdf46a8df53e1067f3b2fb0b7"
40
+ "gitHead": "9a613a18b22c794c0e3eed734c4b6963e905f68d"
41
41
  }