1.1.0 • Published 4 years ago

var-sub v1.1.0

Weekly downloads
1
License
ISC
Repository
-
Last release
4 years ago

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" }
);
1.1.0

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago