Comparing version 0.7.1 to 0.8.0
@@ -12,5 +12,9 @@ #!/usr/bin/env node | ||
.option("-c, --configPath", "specify the location of the configuration file") | ||
.option( | ||
"-C, --cache", | ||
"force Sourcebit to use a filesystem cache, even when `watch` is disabled" | ||
) | ||
.option("-w, --watch", "run continuously in watch mode") | ||
.option("-q, --quiet", "disable logging messages to the console") | ||
.action(({ configPath: customConfigPath, watch }) => { | ||
.action(({ cache, configPath: customConfigPath, quiet, watch }) => { | ||
const configPath = path.resolve( | ||
@@ -22,2 +26,4 @@ process.cwd(), | ||
const runtimeParameters = { | ||
cache, | ||
quiet, | ||
watch | ||
@@ -24,0 +30,0 @@ }; |
@@ -9,3 +9,3 @@ const fs = require("fs"); | ||
filePath, | ||
{ body = "", frontmatter } | ||
{ body = "", frontmatter = {} } | ||
) => { | ||
@@ -16,3 +16,3 @@ const lines = [ | ||
"---", | ||
body.length > 0 ? body.trim() : "", | ||
body ? body.toString().trim() : "", | ||
"" | ||
@@ -19,0 +19,0 @@ ]; |
@@ -32,2 +32,8 @@ const debug = require("debug"); | ||
this.runtimeParameters = runtimeParameters; | ||
this.isCacheEnabled = Boolean( | ||
runtimeParameters.cache === undefined | ||
? runtimeParameters.watch | ||
: runtimeParameters.cache | ||
); | ||
} | ||
@@ -98,3 +104,3 @@ | ||
loadContextFromCache() { | ||
if (this.runtimeParameters.cache === false) return; | ||
if (!this.isCacheEnabled) return; | ||
@@ -163,3 +169,3 @@ try { | ||
saveContextToCache() { | ||
if (this.runtimeParameters.cache === false) return; | ||
if (!this.isCacheEnabled) return; | ||
@@ -200,2 +206,3 @@ const serializedCache = JSON.stringify(this.context); | ||
const contextSnapshot = cloneDeep(this.context); | ||
const onTransformEndCallbacks = []; | ||
const queue = this.pluginBlocks.reduce((queue, pluginBlock, index) => { | ||
@@ -216,2 +223,14 @@ // If the plugin hasn't been bootstrapped, we don't want to run its | ||
if (typeof plugin.onTransformEnd === "function") { | ||
onTransformEndCallbacks.push({ | ||
args: { | ||
debug: this.getDebugMethodForPlugin(pluginName), | ||
getPluginContext: () => contextSnapshot[pluginName] || {}, | ||
log: this.logFromPlugin.bind(this), | ||
options: this.parsePluginOptions(plugin, pluginBlock.options) | ||
}, | ||
callback: plugin.onTransformEnd | ||
}); | ||
} | ||
return plugin.transform({ | ||
@@ -246,2 +265,6 @@ data, | ||
onTransformEndCallbacks.forEach(({ args, callback }) => { | ||
callback({ ...args, data }); | ||
}); | ||
if (typeof this.onTransform === "function") { | ||
@@ -248,0 +271,0 @@ this.onTransform(null, data); |
{ | ||
"name": "sourcebit", | ||
"version": "0.7.1", | ||
"version": "0.8.0", | ||
"description": "Sourcebit helps developers build data-driven JAMstack sites by pulling data from any third-party resource", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -29,3 +29,3 @@ <img alt="Sourcebit logo" src="https://raw.githubusercontent.com/stackbithq/sourcebit/master/Sourcebit.svg?sanitize=true" width="300"> | ||
[![](https://img.youtube.com/vi/fPvfeP1lzTY/0.jpg)](https://www.youtube.com/watch?v=fPvfeP1lzTY) | ||
[![](http://i3.ytimg.com/vi/fPvfeP1lzTY/maxresdefault.jpg)](https://www.youtube.com/watch?v=fPvfeP1lzTY) | ||
@@ -32,0 +32,0 @@ Sourcebit works through the use of two types of plugins: |
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
23771
374