How to use the @jsii/spec.validateAssembly function in @jsii/spec

To help you get started, we’ve selected a few @jsii/spec 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 aws / jsii / packages / jsii / lib / project-info.ts View on Github external
async function loadAndValidateAssembly(jsiiFileName: string): Promise {
  if (!ASSEMBLY_CACHE.has(jsiiFileName)) {
    ASSEMBLY_CACHE.set(jsiiFileName, spec.validateAssembly(await fs.readJson(jsiiFileName)));
  }
  return ASSEMBLY_CACHE.get(jsiiFileName)!;
}
github aws / jsii / packages / jsii-diff / bin / jsii-diff.ts View on Github external
async function loadPackageNameFromAssembly(options: LoadOptions): Promise {
  const JSII_ASSEMBLY_FILE = '.jsii';
  if (!await fs.pathExists(JSII_ASSEMBLY_FILE)) {
    throw new Error(`No NPM package name given and no ${JSII_ASSEMBLY_FILE} file in the current directory. Please specify a package name.`);
  }
  const contents = await fs.readJSON(JSII_ASSEMBLY_FILE, { encoding: 'utf-8' });
  const module = options.validate ? spec.validateAssembly(contents) : contents as spec.Assembly;
  if (!module.name) { throw new Error(`Could not find package in ${JSII_ASSEMBLY_FILE}`); }

  return module.name;
}
github aws / jsii / packages / jsii-rosetta / lib / jsii / assemblies.ts View on Github external
async function loadAssemblyFromFile(filename: string) {
  const contents = await fs.readJSON(filename, { encoding: 'utf-8' });
  return spec.validateAssembly(contents);
}
github aws / jsii / packages / jsii-reflect / lib / type-system.ts View on Github external
private async loadAssembly(file: string, validate = true) {
    const spec = JSON.parse((await readFile(file)).toString());
    const ass = validate ? jsii.validateAssembly(spec) : spec as jsii.Assembly;
    return new Assembly(this, ass);
  }