mirror of
https://github.com/GoogleChrome/chrome-extensions-samples.git
synced 2026-03-26 13:19:49 +07:00
* init project * init .gitignore * Add main scripts * Add prefetch script * Add extension-apis.json * Add README.md * Update comments * Add newline to .gitignore * Update type definition * Update extension api json loading. * Update README.md * Update deps * Pin deps versions * Update extension-apis.json * Update prefetch script * Update script * Remove type definitions prefix * Add comment to auto generated json * Split utils * Update types * Add manifest utils * refactor * Reject if there is a babel error. * Add parallel support * Remove redundant import * loadExtensionApis execute synchronously * Add test deps * Fix unexpected result * Add test scripts * Update type definition * Add start function * Rename api variable * Fix test * Update getApiType method * Remove singularize * Fix loadExtensionApis return signature * Remove parallel controller * Update type definition * Add comments * Update types * Update api detector * Fix api test * Add more test cases * Remove `$special` key * Fix typo * Simplify code * Rename `apiType` to `type` * Add warning if no api found * Rename variable * Update getFullMemberExpression * Remove the special case for `chrome.storage`. * Add getManifest function * Revoke changes * Fix crash caused by incorrect folder detection * Remove redundant import * Check property type with typedoc * Add action * Fix wrong node version * Update code * Rename variable * Remove unnecessary Map * Update README * Fix typo * Remove unnecessary output * Add comments * Remove the judgment on storage API. * Update test case * Update comments * Extract `getAllJsFile()` into the filesystem util * Explain how to run the tests in README * Pin deps * Extract variable * Extract `isDirectory()` into the filesystem util * Remove assertion * Update the parameter of `extractApiCalls()` * Update tests * Remove action
20 lines
582 B
TypeScript
20 lines
582 B
TypeScript
import path from 'path';
|
|
import fs from 'fs';
|
|
import type { ExtensionApiMap } from '../types';
|
|
import { isFileExistsSync } from '../utils/filesystem';
|
|
|
|
export const loadExtensionApis = (): ExtensionApiMap => {
|
|
const filePath = path.join(__dirname, '../../extension-apis.json');
|
|
|
|
// check if extension-apis.json exists
|
|
if (!isFileExistsSync(filePath)) {
|
|
console.error(
|
|
'extension-apis.json does not exist. Please run "npm run prepare-chrome-types" first.'
|
|
);
|
|
process.exit(1);
|
|
}
|
|
|
|
let data = fs.readFileSync(filePath, 'utf8');
|
|
return JSON.parse(data);
|
|
};
|