Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sourcebit-source-filesystem

Package Overview
Dependencies
Maintainers
11
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sourcebit-source-filesystem - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

2

package.json
{
"name": "sourcebit-source-filesystem",
"version": "0.1.2",
"version": "0.1.3",
"description": "Sourcebit filesystem source plugin",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -34,2 +34,3 @@ const chokidar = require('chokidar');

if (stackbitYamlExists) {
log('loading stackbit.yaml and models...');
const { models, stackbitYaml } = await loadStackbitYaml(stackbitYamlPath)

@@ -56,10 +57,22 @@ setPluginContext({ models, stackbitYaml });

if (watch) {
const update = async (eventName, path) => {
log(`file '${path}' has been ${eventName}, reloading files...`);
let changedFilePaths = [];
if (path === stackbitYamlFileName) {
const { models, stackbitYaml } = loadStackbitYaml(stackbitYamlPath)
// don't call refresh on every file change, as multiple files could be written at once.
// instead, debounce the update function for 50ms, up to 200ms
const debouncedUpdate = _.debounce(async () => {
log(`reload files and refresh sourcebit plugins...`);
const filePathsCopy = changedFilePaths.slice();
changedFilePaths = [];
if (filePathsCopy.includes(stackbitYamlFileName)) {
log('reloading stackbit.yaml and models...');
const { models, stackbitYaml } = await loadStackbitYaml(stackbitYamlPath)
setPluginContext({ models, stackbitYaml });
} else {
}
if (_.some(filePathsCopy, filePath => filePath !== stackbitYamlFileName)) {
log('reloading content files...');
const files = await readFiles(sources);
log(`loaded ${files.length} files`);
setPluginContext({ files });

@@ -69,2 +82,8 @@ }

refresh();
}, 50, {maxWait: 200});
const update = async (eventName, filePath) => {
log(`file '${filePath}' has been ${eventName}, reloading files...`);
changedFilePaths.push(filePath);
await debouncedUpdate();
};

@@ -71,0 +90,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc