Newts Parading Majestically

    var-sub
    TypeScript icon, indicating that this package has built-in type declarations

    1.1.0 • Public • Published

    var-sub

    Bash style variable substitutions.

    String replacements

    await stringFromTemplate(`foo $BAR`, {
      BAR: "baz"
    }); // foo baz
     
    await stringFromTemplate("foo ${bar}", {
      BAR: "baz"
    }); // foo baz
     
    await stringFromTemplate("my home dir is $HOME", {
      ...process.env
    }); // my home dir is /Users/joeflateau
     
    await stringFromTemplate(
      await request.get("https://example.org/some/template"),
      {
        FOO: "bar"
      }
    );

    File replacements

    await stringFromTemplateFile(__dirname + "/cloudfront.template.json", {
      VIEWER_REQUEST_FUNCTION_ARN: viewerRequestFunctionArn,
      ORIGIN_RESPONSE_FUNCTION_ARN: originResponseFunctionArn,
      CALLER_REFERENCE: callerReference,
      STAGE,
      CNAME 
    });

    Recursive copy w/ replacements

    await copyFromTemplateFiles(
      __dirname + "/../srcDir",
      "./**/*.txt",
      __dirname + "/../destDir",
      { BAR: "bar" }
    );

    Install

    npm i var-sub

    DownloadsWeekly Downloads

    8

    Version

    1.1.0

    License

    ISC

    Unpacked Size

    15.2 kB

    Total Files

    6

    Last publish

    Collaborators

    • joeflateau