How to use fs-plus - 10 common examples

To help you get started, we’ve selected a few fs-plus 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 / archive-view / lib / archive-editor.js View on Github external
return atom.workspace.addOpener((filePath = '') => {
      // Check that filePath exists before opening, in case a remote URI was given
      if (isPathSupported(filePath) && fs.isFileSync(filePath)) {
        return new ArchiveEditor({path: filePath})
      }
    })
  }
github atom / git-utils / spec / git-spec.js View on Github external
it('returns the status of only that path2', () => {
        fs.writeFileSync(filePath, '', 'utf8')

        const statuses = repo.getStatusForPaths(['dir/**'])
        expect(_.keys(statuses).length).toBe(0)
      })
    })
github atom / atom / spec / git-repository-spec.js View on Github external
it('gets the status based on the files inside the directory', () => {
      expect(
        repo.isStatusModified(repo.getDirectoryStatus(directoryPath))
      ).toBe(false);
      fs.writeFileSync(filePath, 'abc');
      repo.getPathStatus(filePath);
      expect(
        repo.isStatusModified(repo.getDirectoryStatus(directoryPath))
      ).toBe(true);
    });
  });
github atom / atom / spec / git-repository-spec.js View on Github external
it('trigger a status-changed event when the new status differs from the last cached one', () => {
      const statusHandler = jasmine.createSpy('statusHandler');
      repo.onDidChangeStatus(statusHandler);
      fs.writeFileSync(filePath, '');
      let status = repo.getPathStatus(filePath);
      expect(statusHandler.callCount).toBe(1);
      expect(statusHandler.argsForCall[0][0]).toEqual({
        path: filePath,
        pathStatus: status
      });

      fs.writeFileSync(filePath, 'abc');
      status = repo.getPathStatus(filePath);
      expect(statusHandler.callCount).toBe(1);
    });
  });
github izuzak / atom-pdf-view / lib / pdf-editor.js View on Github external
export function deserialize({filePath, scale, scrollTop, scrollLeft}) {
  if (require('fs-plus').isFileSync(filePath)) {
    if (PdfEditorView === null) {
      PdfEditorView = require('./pdf-editor-view');
    }
    return new PdfEditorView(filePath, scale, scrollTop, scrollLeft);
  } else {
    console.warn("Could not deserialize PDF editor for path '#{filePath}' because that file no longer exists");
  }
}
github atom / atom / spec / git-repository-spec.js View on Github external
it('returns true if the path is deleted', () => {
        fs.removeSync(filePath);
        expect(repo.isPathModified(filePath)).toBeTruthy();
      });
github atom / git-utils / spec / git-spec.js View on Github external
beforeEach(() => {
      repoDirectory = temp.mkdirSync('node-git-repo-')
      wrench.copyDirSyncRecursive(path.join(__dirname, 'fixtures/subdir.git'), path.join(repoDirectory, '.git'))
      repo = git.open(repoDirectory)

      const dir = path.join(repo.getWorkingDirectory(), 'dir')
      filePath = path.join(dir, 'a.txt')
      fs.writeFileSync(filePath, 'hey there', 'utf8')
    })
github microsoft / vscode-iot-workbench / src / Models / RaspberryPiYoctoDevice.ts View on Github external
generateYoctoConfig(folder: string) {
    const filePath = path.join(folder, LocalConstants.configFileName);
    if (!fs.existsSync(filePath)) {
      const config:
          RaspberryPiYoctoConfig = {output: LocalConstants.defaultOutputPath};
      fs.writeFileSync(filePath, JSON.stringify(config, null, 4));
    }
  }
}
github atom / atom / src / compile-cache.js View on Github external
function readCachedJavaScript (relativeCachePath) {
  var cachePath = path.join(cacheDirectory, relativeCachePath)
  if (fs.isFileSync(cachePath)) {
    try {
      return fs.readFileSync(cachePath, 'utf8')
    } catch (error) {}
  }
  return null
}
github nylas-mail-lives / nylas-mail / packages / client-app / src / compile-cache.js View on Github external
function readCachedJavascript(relativeCachePath) {
  const cachePath = path.join(cacheDirectory, relativeCachePath)
  if (fs.isFileSync(cachePath)) {
    try {
      return fs.readFileSync(cachePath, 'utf8')
    } catch (error) {
      //
    }
  }
  return null
}

fs-plus

node's fs with more helpers

MIT
Latest version published 6 years ago

Package Health Score

50 / 100
Full package analysis