How to use the proper-lockfile.lockSync function in proper-lockfile

To help you get started, we’ve selected a few proper-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 mjackson / unpkg / server / utils / getPackage.js View on Github external
fs.access(outputDir, error => {
    if (error) {
      if (error.code === "ENOENT" || error.code === "ENOTDIR") {
        // ENOENT or ENOTDIR are to be expected when we haven't yet
        // fetched a package for the first time. Carry on!
        mkdirp.sync(outputDir);
        const release = lockfile.lockSync(outputDir);

        fetchPackage(tarballURL, outputDir).then(
          () => {
            release();
            callback(null, outputDir);
          },
          error => {
            release();
            callback(error);
          }
        );
      } else {
        callback(error);
      }
    } else {
      lockfile.check(outputDir).then(locked => {
github automerge / hypermerge / src / RepoBackend.ts View on Github external
constructor(opts: Options) {
    this.opts = opts
    this.path = opts.path || 'default'

    // initialize storage
    if (!opts.memory) {
      ensureDirectoryExists(this.path)
      // Attempt to acquite a lock on the repo to prevent concurrent corrupting access.
      this.lockRelease = lockfile.lockSync(this.path)
    }
    this.storage = opts.memory ? ram : raf
    this.db = SqlDatabase.open(path.resolve(this.path, 'hypermerge.db'), opts.memory || false)

    this.keys = new KeyStore(this.db)
    this.feeds = new FeedStore(this.db, (path: string) => this.storageFn('feeds/' + path))
    this.files = new FileStore(this.feeds)

    // init repo
    const repoKeys = this.keys.get('self.repo') || this.keys.set('self.repo', Keys.createBuffer())
    this.swarmKey = repoKeys.publicKey
    this.id = encodeRepoId(repoKeys.publicKey)

    // initialize the various stores
    this.cursors = new CursorStore(this.db)
    this.clocks = new ClockStore(this.db)
github muffinista / before-dawn / src / lib / prefs.js View on Github external
writeSync() {
    let output = JSON.stringify(this._data, null, 2);
    let release = lockfile.lockSync(this.configFile, { realpath: false });

    fs.writeFileSync(this.configFile, output);
    release();
  }
github jspm / jspm-cli / lib / config / config-file.js View on Github external
lock(symlink = true) {
        try {
            this._unlock = lockfile.lockSync(this.fileName, symlink ? undefined : { realpath: false });
            this.locked = true;
        }
        catch (e) {
            if (symlink && e.code === 'ENOENT')
                return this.lock(false);
            if (e.code === 'ELOCKED')
                throw new common_1.JspmUserError(`Configuration file ${common_1.bold(this.fileName)} is currently locked by another jspm process.`);
            throw e;
        }
    }
    unlock() {
github jspm / jspm-cli / lib / config / global-config.js View on Github external
GlobalConfigFile.prototype.lock = function() {
  if (!this._unlock) {
    try {
      this._unlock = lockFile.lockSync(this.globalConfigFile, {
        retries: {
          retries: 10,
          minTimeout: 20,
          maxTimeout: 300,
          randomize: true
        },
        realpath: false
      });
    } catch (e) {
      if (e.code === 'ELOCKED')
        throw 'Unable to lock global config file %' + this.globalConfigFile + '%, not overwriting';
    }
  }
};
GlobalConfigFile.prototype.unlock = function() {

proper-lockfile

A inter-process and inter-machine lockfile utility that works on a local or network file system

MIT
Latest version published 4 years ago

Package Health Score

74 / 100
Full package analysis