How to use fs-admin - 2 common examples

To help you get started, we’ve selected a few fs-admin 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 atom / text-buffer / src / text-buffer.js View on Github external
})
        destination = filePath
      } else {
        destination = file.createWriteStream()
      }

      await this.emitter.emitAsync('will-save', {path: filePath})

      try {
        await this.buffer.save(destination, this.getEncoding())
      } catch (error) {
        const canEscalate = process.platform === 'darwin' || process.platform === 'linux'
        if (error.code === 'EACCES' && destination === filePath && canEscalate) {
          const fsAdmin = require('fs-admin')
          try {
            await this.buffer.save(fsAdmin.createWriteStream(filePath), this.getEncoding())
          } catch (_) {
            throw error
          }
        } else {
          throw error
        }
      }
    } finally {
      this.outstandingSaveCount--
    }

    this.setFile(file)
    this.fileHasChangedSinceLastLoad = false
    this.digestWhenLastPersisted = this.buffer.baseTextDigest()
    this.loaded = true
    this.emitModifiedStatusChanged(false)
github atom / atom / script / lib / install-application.js View on Github external
return new Promise((resolve, reject) => {
        fsAdmin.recursiveCopy(packagedAppPath, installationDirPath, error => {
          error ? reject(error) : resolve();
        });
      });
    }

fs-admin

Manipulate files with escalated privileges

MIT
Latest version published 2 years ago

Package Health Score

48 / 100
Full package analysis