How to use read-cmd-shim - 5 common examples

To help you get started, we’ve selected a few read-cmd-shim 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 lerna / lerna / test / FileSystemUtilities.js View on Github external
it("returns false when filePath is not a shimmed executable", () => {
        const filePath = path.resolve("./packages/package-1/node_modules/.bin/package-2");
        fs.lstatSync.mockImplementation(() => ({
          isSymbolicLink: () => false,
          isFile: () => true,
        }));
        readCmdShim.sync.mockImplementation(() => {
          throw new Error("ENOTASHIM");
        });
        expect(FileSystemUtilities.isSymlink(filePath)).toBe(false);
      });
github lerna / lerna / test / FileSystemUtilities.js View on Github external
it("returns resolved path of a shimmed executable", () => {
        const original = path.resolve("./packages/package-2/cli.js");
        const filePath = path.resolve("./packages/package-1/node_modules/.bin/package-2.cmd");
        fs.lstatSync.mockImplementation(() => ({
          isSymbolicLink: () => false,
          isFile: () => true,
        }));
        readCmdShim.sync.mockImplementation(() => linkRelative(original, filePath));
        expect(FileSystemUtilities.isSymlink(filePath)).toBe(original);
      });
    });
github lerna / lerna / utils / resolve-symlink / resolve-symlink.js View on Github external
function resolveWindowsSymlink(filePath) {
  const { resolvedPath, lstat } = resolveSymbolicLink(filePath);

  if (lstat.isFile() && !resolvedPath) {
    try {
      return path.resolve(path.dirname(filePath), readCmdShim.sync(filePath));
    } catch (e) {
      return false;
    }
  }

  return resolvedPath && path.resolve(resolvedPath);
}
github lerna / lerna / utils / resolve-symlink / resolve-symlink.js View on Github external
function resolveWindowsSymlink(filePath) {
  const { resolvedPath, lstat } = resolveSymbolicLink(filePath);

  if (lstat.isFile() && !resolvedPath) {
    try {
      return path.resolve(path.dirname(filePath), readCmdShim.sync(filePath));
    } catch (e) {
      return false;
    }
  }

  return resolvedPath && path.resolve(resolvedPath);
}
github boltpkg / bolt / src / utils / fs.js View on Github external
  return promisify(cb => _readCmdShim(filePath, cb));
}

read-cmd-shim

Figure out what a cmd-shim is pointing at. This acts as the equivalent of fs.readlink.

ISC
Latest version published 3 months ago

Package Health Score

86 / 100
Full package analysis

Popular read-cmd-shim functions

Similar packages