sourcebit-source-filesystem
Advanced tools
Comparing version 0.1.4 to 0.1.5
{ | ||
"name": "sourcebit-source-filesystem", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "Sourcebit filesystem source plugin", | ||
@@ -29,3 +29,3 @@ "main": "src/index.js", | ||
"@stackbit/sdk": "^0.2.16", | ||
"@stackbit/utils": "^0.1.0", | ||
"@stackbit/utils": "^0.2.1", | ||
"chokidar": "^3.5.2", | ||
@@ -32,0 +32,0 @@ "fs-extra": "^10.0.0", |
@@ -6,3 +6,3 @@ const chokidar = require('chokidar'); | ||
const { loadConfig } = require('@stackbit/sdk'); | ||
const { parseFile, mapPromise, readDirRecursively } = require('@stackbit/utils'); | ||
const { parseFile, mapPromise, reducePromise, readDirRecursively } = require('@stackbit/utils'); | ||
const { matchObjectsToModels } = require('./models-matcher'); | ||
@@ -28,2 +28,6 @@ | ||
function logError(message) { | ||
console.error(`[${SOURCE}] ${message}`); | ||
} | ||
module.exports.bootstrap = async ({ setPluginContext, options, refresh }) => { | ||
@@ -142,20 +146,25 @@ let { watch, sources = [] } = options; | ||
}).sort(); | ||
return mapPromise(filePaths, async filePath => { | ||
return reducePromise(filePaths, async (result, filePath) => { | ||
const absFilePath = path.join(absSourcePath, filePath); | ||
const data = await parseFile(absFilePath); | ||
const relProjectPath = path.relative(absProjectPath, absFilePath); | ||
const relSourcePath = path.relative(absSourcePath, absFilePath); | ||
return _.assign({ | ||
__metadata: { | ||
id: `${relProjectPath}`, | ||
source: SOURCE, | ||
sourceName: name, | ||
sourcePath: sourcePath, | ||
relSourcePath: relSourcePath, | ||
relProjectPath: relProjectPath | ||
} | ||
}, data); | ||
}); | ||
try { | ||
const data = await parseFile(absFilePath); | ||
result.push(_.assign({ | ||
__metadata: { | ||
id: `${relProjectPath}`, | ||
source: SOURCE, | ||
sourceName: name, | ||
sourcePath: sourcePath, | ||
relSourcePath: relSourcePath, | ||
relProjectPath: relProjectPath | ||
} | ||
}, data)); | ||
} catch (error) { | ||
logError(`failed to parse file: ${relProjectPath}`); | ||
} | ||
return result; | ||
}, []); | ||
}); | ||
return _.chain(result).flatten().value(); | ||
} |
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
16585
326
- Removed@stackbit/utils@0.1.2(transitive)
- Removedargparse@1.0.10(transitive)
- Removedesprima@4.0.1(transitive)
- Removedjs-yaml@3.14.1(transitive)
- Removedsprintf-js@1.0.3(transitive)
Updated@stackbit/utils@^0.2.1