How to use the google-closure-deps.parser.parseFileAsync 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 / dependency-parser.ts View on Github external
export async function parseDependency(filepath: string): Promise {
  const result = await parser.parseFileAsync(filepath);
  if (result.hasFatalError) {
    throw new Error(`Fatal parse error in ${filepath}: ${result.errors}`);
  }
  if (result.dependencies.length > 1) {
    throw new Error(`A JS file must have only one dependency: ${filepath}`);
  }
  if (result.dependencies.length === 0) {
    throw new Error(`No dependencies found: ${filepath}`);
  }
  return result.dependencies[0];
}