How to use the google-closure-deps.parser.parseDependencyFile function in google-closure-deps

To help you get started, we’ve selected a few google-closure-deps 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 teppeis / duck / src / gendeps.ts View on Github external
export async function restoreDepsJs(depsJsPath: string, closureLibraryDir: string): Promise {
  let depsText = "";
  try {
    depsText = await readFile(depsJsPath, "utf8");
  } catch (e) {
    throw new Error(`${depsJsPath} doesn't exist. Run \`duck build:deps\`. ${e}`);
  }
  const result = parser.parseDependencyFile(depsText, depsJsPath);
  if (result.hasFatalError) {
    throw new Error(`Fatal parse error in ${depsJsPath}: ${result.errors}`);
  }
  appendGoogImport(result.dependencies, path.join(closureLibraryDir, "closure", "goog"));
  result.dependencies.forEach(dep => {
    pathToDependencyCache.set(dep.path, Promise.resolve(dep));
  });
}
github teppeis / duck / src / gendeps.ts View on Github external
export async function getClosureLibraryDependencies(
  closureLibraryDir: string
): Promise {
  const googDepsPath = path.join(closureLibraryDir, "closure", "goog", "deps.js");
  const depsContent = await readFile(googDepsPath, "utf8");
  const result = parser.parseDependencyFile(depsContent, googDepsPath);
  if (result.errors.length > 0) {
    throw new Error(`Fail to parse deps.js of Closure Library: ${result.errors.join(", ")}`);
  }
  appendGoogImport(result.dependencies, path.dirname(googDepsPath));
  return result.dependencies;
}