All files / src statement.ts

100% Statements 29/29
100% Branches 6/6
100% Functions 2/2
100% Lines 29/29

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 301x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 11x 1x 1x 10x 10x 1x 1x 1x 1x 1x 1x 1x 4x 1x 1x 3x 3x 1x  
import { readFileSync } from 'fs';
/*
 * Represents the Policy Statement.
 */
export class Statement {
  /**
   * Inline statement for policy
   * @returns `InlineStatement` with inline statement.
   * @param statement The actual statement
   */
  public static fromInline(statement: string): string {
    if (statement.length === 0) {
      throw new Error('Policies inline statement cannot be empty');
    }
    return statement;
  }
 
  /**
   * Loads the statement from a local disk path.
   * @returns `DirectoryStatement` with statement from file path.
   * @param path A path with the policy statement
   */
  public static fromFile(path: string): string {
    if (path.length === 0) {
      throw new Error('Policy path cannot be empty');
    }
    return readFileSync(path, 'utf-8');
  }
}