Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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));
});
}
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;
}