How to use where clause in Knex
Create refunds with Stripe
Load HTML with Cheerio
How to send POST request with Axios
Find intersection of array in Lodash
Powered by Official white Bloop logo with a period

Terms / Privacy / Search / Support

  • import { Architect } from "@angular-devkit/architect";
    import { TestingArchitectHost } from "@angular-devkit/architect/testing";
    import { schema } from "@angular-devkit/core";
    import { promises as fs } from "fs";
    
    describe("Copy File Builder", () => {
      let architect: Architect;
      let architectHost: TestingArchitectHost;
    
      beforeEach(async () => {
        const registry = new schema.CoreSchemaRegistry();
        registry.addPostTransform(
          schema.transforms.addUndefinedDefaults
        );
    
        // TestingArchitectHost() takes workspace and current directories.
        // Since we don't use those, both are the same in this case.
        architectHost = new TestingArchitectHost(
          __dirname,
          __dirname
        );
        architect = new Architect(architectHost, registry);
    
        // This will either take a Node package name, or a path to the directory
        // for the package.json file.
        await architectHost.addBuilderFromPackage("..");
      });
    
      it("can copy files", async () => {
        // A "run" can have multiple outputs, and contains progress information.
        const run = await architect.scheduleBuilder(
          "@example/copy-file:copy",
          {
            source: "package.json",
            destination: "package-copy.json",
          }
        );
    
        // The "result" member (of type BuilderOutput) is the next output.
        const output = await run.result;
    
        // Stop the builder from running. This stops Architect from keeping
        // the builder-associated states in memory, since builders keep waiting
        // to be scheduled.
        await run.stop();
    
        // Expect that the copied file is the same as its source.
        const sourceContent = await fs.readFile(
          "package.json",
          "utf8"
        );
        const destinationContent = await fs.readFile(
          "package-copy.json",
          "utf8"
        );
        expect(destinationContent).toBe(sourceContent);
      });
    });
    
    Docs
    0
  • import { Architect } from "@angular-devkit/architect";
    import { TestingArchitectHost } from "@angular-devkit/architect/testing";
    import { schema } from "@angular-devkit/core";
    import { promises as fs } from "fs";
    
    describe("Copy File Builder", () => {
      let architect: Architect;
      let architectHost: TestingArchitectHost;
    
      beforeEach(async () => {
        const registry = new schema.CoreSchemaRegistry();
        registry.addPostTransform(
          schema.transforms.addUndefinedDefaults
        );
    
        // TestingArchitectHost() takes workspace and current directories.
        // Since we don't use those, both are the same in this case.
        architectHost = new TestingArchitectHost(
          __dirname,
          __dirname
        );
        architect = new Architect(architectHost, registry);
    
        // This will either take a Node package name, or a path to the directory
        // for the package.json file.
        await architectHost.addBuilderFromPackage("..");
      });
    
      it("can copy files", async () => {
        // A "run" can have multiple outputs, and contains progress information.
        const run = await architect.scheduleBuilder(
          "@example/copy-file:copy",
          {
            source: "package.json",
            destination: "package-copy.json",
          }
        );
    
        // The "result" member (of type BuilderOutput) is the next output.
        const output = await run.result;
    
        // Stop the builder from running. This stops Architect from keeping
        // the builder-associated states in memory, since builders keep waiting
        // to be scheduled.
        await run.stop();
    
        // Expect that the copied file is the same as its source.
        const sourceContent = await fs.readFile(
          "package.json",
          "utf8"
        );
        const destinationContent = await fs.readFile(
          "package-copy.json",
          "utf8"
        );
        expect(destinationContent).toBe(sourceContent);
      });
    });
    
    Docs
    0
  • import {
      BuilderContext,
      BuilderOutput,
      createBuilder,
    } from "@angular-devkit/architect";
    import { JsonObject } from "@angular-devkit/core";
    import { promises as fs } from "fs";
    
    interface Options extends JsonObject {
      source: string;
      destination: string;
    }
    
    export default createBuilder(copyFileBuilder);
    
    async function copyFileBuilder(
      options: Options,
      context: BuilderContext
    ): Promise {
      context.reportStatus(
        `Copying ${options.source} to ${options.destination}.`
      );
      try {
        await fs.copyFile(options.source, options.destination);
      } catch (err) {
        context.logger.error("Failed to copy file.");
        return {
          success: false,
          error: err.message,
        };
      }
    
      context.reportStatus("Done.");
      return { success: true };
    }
    
    Docs
    0
  • import {
      BuilderContext,
      BuilderOutput,
      createBuilder,
    } from "@angular-devkit/architect";
    import { JsonObject } from "@angular-devkit/core";
    
    interface Options extends JsonObject {
      source: string;
      destination: string;
    }
    
    export default createBuilder(copyFileBuilder);
    
    async function copyFileBuilder(
      options: Options,
      context: BuilderContext
    ): Promise {}
    
    Docs
    0
  • import {
      BuilderContext,
      BuilderOutput,
      createBuilder,
    } from "@angular-devkit/architect";
    import { JsonObject } from "@angular-devkit/core";
    import { promises as fs } from "fs";
    
    interface Options extends JsonObject {
      source: string;
      destination: string;
    }
    
    export default createBuilder(copyFileBuilder);
    
    async function copyFileBuilder(
      options: Options,
      context: BuilderContext
    ): Promise {
      try {
        await fs.copyFile(options.source, options.destination);
      } catch (err) {
        context.logger.error("Failed to copy file.");
        return {
          success: false,
          error: err.message,
        };
      }
    
      return { success: true };
    }
    
    Docs
    0
  • import {
      BuilderContext,
      BuilderOutput,
      createBuilder,
    } from "@angular-devkit/architect";
    import { JsonObject } from "@angular-devkit/core";
    import { promises as fs } from "fs";
    
    interface Options extends JsonObject {
      source: string;
      destination: string;
    }
    
    export default createBuilder(copyFileBuilder);
    
    async function copyFileBuilder(
      options: Options,
      context: BuilderContext
    ): Promise {
      try {
        await fs.copyFile(options.source, options.destination);
      } catch (err) {
        return {
          success: false,
          error: err.message,
        };
      }
    
      return { success: true };
    }
    
    Docs
    0
  • import { Architect } from "@angular-devkit/architect";
    import { TestingArchitectHost } from "@angular-devkit/architect/testing";
    import { schema } from "@angular-devkit/core";
    import { promises as fs } from "fs";
    
    describe("Copy File Builder", () => {
      let architect: Architect;
      let architectHost: TestingArchitectHost;
    
      beforeEach(async () => {
        const registry = new schema.CoreSchemaRegistry();
        registry.addPostTransform(
          schema.transforms.addUndefinedDefaults
        );
    
        // TestingArchitectHost() takes workspace and current directories.
        // Since we don't use those, both are the same in this case.
        architectHost = new TestingArchitectHost(
          __dirname,
          __dirname
        );
        architect = new Architect(architectHost, registry);
    
        // This will either take a Node package name, or a path to the directory
        // for the package.json file.
        await architectHost.addBuilderFromPackage("..");
      });
    
      it("can copy files", async () => {
        // A "run" can have multiple outputs, and contains progress information.
        const run = await architect.scheduleBuilder(
          "@example/copy-file:copy",
          {
            source: "package.json",
            destination: "package-copy.json",
          }
        );
    
        // The "result" member (of type BuilderOutput) is the next output.
        const output = await run.result;
    
        // Stop the builder from running. This stops Architect from keeping
        // the builder-associated states in memory, since builders keep waiting
        // to be scheduled.
        await run.stop();
    
        // Expect that the copied file is the same as its source.
        const sourceContent = await fs.readFile(
          "package.json",
          "utf8"
        );
        const destinationContent = await fs.readFile(
          "package-copy.json",
          "utf8"
        );
        expect(destinationContent).toBe(sourceContent);
      });
    });
    
    Docs
    0
  • import { Architect } from "@angular-devkit/architect";
    import { TestingArchitectHost } from "@angular-devkit/architect/testing";
    import { schema } from "@angular-devkit/core";
    import { promises as fs } from "fs";
    
    describe("Copy File Builder", () => {
      let architect: Architect;
      let architectHost: TestingArchitectHost;
    
      beforeEach(async () => {
        const registry = new schema.CoreSchemaRegistry();
        registry.addPostTransform(
          schema.transforms.addUndefinedDefaults
        );
    
        // TestingArchitectHost() takes workspace and current directories.
        // Since we don't use those, both are the same in this case.
        architectHost = new TestingArchitectHost(
          __dirname,
          __dirname
        );
        architect = new Architect(architectHost, registry);
    
        // This will either take a Node package name, or a path to the directory
        // for the package.json file.
        await architectHost.addBuilderFromPackage("..");
      });
    
      it("can copy files", async () => {
        // A "run" can have multiple outputs, and contains progress information.
        const run = await architect.scheduleBuilder(
          "@example/copy-file:copy",
          {
            source: "package.json",
            destination: "package-copy.json",
          }
        );
    
        // The "result" member (of type BuilderOutput) is the next output.
        const output = await run.result;
    
        // Stop the builder from running. This stops Architect from keeping
        // the builder-associated states in memory, since builders keep waiting
        // to be scheduled.
        await run.stop();
    
        // Expect that the copied file is the same as its source.
        const sourceContent = await fs.readFile(
          "package.json",
          "utf8"
        );
        const destinationContent = await fs.readFile(
          "package-copy.json",
          "utf8"
        );
        expect(destinationContent).toBe(sourceContent);
      });
    });
    
    Docs
    0
  • Powered by Official black Bloop logo with a period
    download the IDE extension

    View other examples