How to use the proper-lockfile.checkSync 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 vesparny / borgjs / lib / cli.js View on Github external
if (!config.repository) {
  console.log(
    chalk.red('The "repository" option must be specified in the config file')
  )
  process.exit(1)
}
const fileLock = path.join(
  osTmpdir(),
  filenamify(config.repository, { replacement: '-' })
)
// ensure the dir exists, otherwise it's impossible to acquire the lock
if (!fs.existsSync(fileLock)) {
  fs.mkdirSync(fileLock)
}
if (fs.existsSync(`${fileLock}.lock`)) {
  if (lockfile.checkSync(fileLock)) {
    console.log(
      chalk.cyan(
        `
      There is probably another borgjs runnign process.
      The look file seems to be locked.

      ${chalk.yellow(fileLock + '.lock')}
    `
      )
    )
    process.exit(1)
  }
}
lockfile.lock(fileLock, err => {
  if (err) {
    console.log(chalk.red(err.message))
github vesparny / borgjs / bin / index.js View on Github external
if (!config.repository) {
  console.log(
    chalk.red('The "repository" option must be specified in the config file')
  )
  process.exit(1)
}
const fileLock = path.join(
  osTmpdir(),
  filenamify(config.repository, { replacement: '-' })
)
// ensure the dir exists, otherwise it's impossible to acquire the lock
if (!fs.existsSync(fileLock)) {
  fs.mkdirSync(fileLock)
}
if (fs.existsSync(`${fileLock}.lock`)) {
  if (lockfile.checkSync(fileLock)) {
    console.log(
      chalk.cyan(
        `
      lockfile detected.
      There is probably another borgjs runnign process.

      ${chalk.yellow(fileLock + '.lock')}
    `
      )
    )
    process.exit(1)
  }
}
lockfile.lock(fileLock, err => {
  if (err) {
    console.log(chalk.red(err.message))

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