How to use lockfile - 10 common examples

To help you get started, we’ve selected a few lockfile examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github owid / owid-grapher / js / screenshot.js View on Github external
additionalFlags: [
      '--window-size=1020,720',
      '--disable-gpu',
      '--headless'
    ]
  });

  return launcher.run().then(() => launcher)
    .catch(err => {
      return launcher.kill().then(() => { // Kill Chrome if there's an error.
        throw err;
      }, console.error);
    });
}

lockfile.lock(output+'.lock', function(err) {
  if (err) {
    // Another process is already working on this. Just wait until it's finished.
    console.log("Waiting for other process")
    lockfile.lock(output+'.lock', { wait: timeout }, function(err) {
        process.exit(0)
    })
  } else {
    run().catch(e => {
      if (e.code == "ECONNREFUSED") {
        launchChrome().then(run).catch(e => {
          console.error(e);
          process.exit(1);
        })
      } else {
        console.error(e);
        process.exit(1);
github GUI / uas-parser / lib / updater.js View on Github external
initialize: function(updateInterval, callback) {
    this.updateInterval = updateInterval;
    this.updateCallback = callback;

    // Perform a lock while updating the cache to ensure only one process
    // is updating the cache at a time.
    lockFile.lock(this.cacheLockPath, { stale: 60 * 1000 }, function(error) {
      if(error) {
        this.finish(null, cache);
        return true;
      }

      fs.stat(this.cachePath, this.handleFileStat.bind(this));
    }.bind(this));
  },
github manifoldco / torus-cli / cli / lib / util / lock.js View on Github external
return new Promise(function (resolve, reject) {
    var lockPath = getLockPath(file);

    /* eslint-disable consistent-return */
    lockfile.lock(lockPath, function (err) {
      if (err) {
        return reject(err);
      }

      resolve();
    });
  });
};
github manifoldco / torus-cli / cli / lib / util / lock.js View on Github external
return new Promise(function (resolve, reject) {
    var lockPath = getLockPath(file);

    /* eslint-disable consistent-return */
    lockfile.unlock(lockPath, function (err) {
      if (err) {
        return reject(err);
      }

      resolve();
    });
  });
};
github OPERANDOH2020 / PlusPrivacy / servers / coreServer / autolib / swarmAnalytics.js View on Github external
fs.appendFile(analyticsFile,temp,function (err,result){
                if(err){
                    logs =temp+logs;
                    num_rows +=currentNrOfRows
                }
                lockFile.unlock(analyticsFile + ".lock", function (err) {
                    if (err) {
                        console.error("Analytics error on unlocking!", err);
                    }
                });
            });
        }
github monaca / monaca-lib / src / monaca.js View on Github external
var unlock = function() {
            lockfile.unlock(lockFile, function(error) {
              if (error) {
                console.error(error);
              }
            });
          };
github rjanicek / bos / scripts / bos.js View on Github external
store.close = function close(returnError) {
			jsonpatch.unobserve(store.data, observer);

			lockFile.unlock(storePath + LOCK_FILE_EXTENSION, function (error) {
				if (error) {
					error.stacktrace = new Error().stack;
					store.emit('error', error);
					if (returnError) { returnError(error); } else { throw error; }
					return;
				}

				store.emit('closed');

				returnError && returnError();
			});
		};
github marklagendijk / WinLess / WinLess / node_modules / npm / lib / cache.js View on Github external
function then () {
    var opts = { stale: npm.config.get("cache-lock-stale")
               , retries: npm.config.get("cache-lock-retries")
               , wait: npm.config.get("cache-lock-wait") }
    var lf = lockFileName(u)
    log.verbose("lock", u, lf)
    lockFile.lock(lf, opts, function(er) {
      if (!er) myLocks[lf] = true
      cb(er)
    })
  }
}
github MobileChromeApps / mobile-chrome-apps / node_modules / cordova / node_modules / npm / lib / cache.js View on Github external
function then () {
    var opts = { stale: npm.config.get("cache-lock-stale")
               , retries: npm.config.get("cache-lock-retries")
               , wait: npm.config.get("cache-lock-wait") }
    var lf = lockFileName(u)
    log.verbose("lock", u, lf)
    lockFile.lock(lf, opts, function(er) {
      if (!er) myLocks[lf] = true
      cb(er)
    })
  }
}
github angelozerr / tern.java / eclipse / tern.eclipse.ide.server.nodejs.embed.linux.gtk.x86 / nodejs / node-v0.10.22-linux-x86 / lib / node_modules / npm / lib / cache.js View on Github external
getCacheStat(function (er, cs) {
    if (er) return cb(er)
    var opts = { stale: npm.config.get("cache-lock-stale")
               , retries: npm.config.get("cache-lock-retries")
               , wait: npm.config.get("cache-lock-wait") }
    var lf = lockFileName(u)
    log.verbose("lock", u, lf)
    lockFile.lock(lf, opts, function(er) {
      if (!er) myLocks[lf] = true
      cb(er)
    })
  })
}

lockfile

A very polite lock file utility, which endeavors to not litter, and to wait patiently for others.

ISC
Latest version published 7 years ago

Package Health Score

55 / 100
Full package analysis

Popular lockfile functions