How to use the @twilio-labs/serverless-api.fsHelpers.getFirstMatchingDirectory function in @twilio-labs/serverless-api

To help you get started, we’ve selected a few @twilio-labs/serverless-api 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 twilio-labs / twilio-run / src / checks / project-structure.ts View on Github external
export async function doesAnyDirectoryExist(
  basePath: string,
  directories: string[]
): Promise {
  let foundDirectories: string | undefined;
  try {
    foundDirectories = fsHelpers.getFirstMatchingDirectory(
      basePath,
      directories
    );
  } catch {
    foundDirectories = undefined;
  }

  if (typeof foundDirectories !== 'undefined') {
    return true;
  }

  return false;
}
github twilio-labs / twilio-run / src / templating / filesystem.ts View on Github external
export async function writeFiles(
  files: TemplateFileInfo[],
  targetDir: string,
  namespace: string
): Promise {
  const functionsDir = fsHelpers.getFirstMatchingDirectory(targetDir, [
    'functions',
    'src',
  ]);
  const assetsDir = fsHelpers.getFirstMatchingDirectory(targetDir, [
    'assets',
    'static',
  ]);
  const functionsTargetDir = path.join(functionsDir, namespace);
  const assetsTargetDir = path.join(assetsDir, namespace);

  if (functionsTargetDir !== functionsDir) {
    if (hasFilesOfType(files, 'functions')) {
      try {
        await mkdir(functionsTargetDir);
      } catch (err) {
        debug(err);
github twilio-labs / twilio-run / src / templating / filesystem.ts View on Github external
export async function writeFiles(
  files: TemplateFileInfo[],
  targetDir: string,
  namespace: string
): Promise {
  const functionsDir = fsHelpers.getFirstMatchingDirectory(targetDir, [
    'functions',
    'src',
  ]);
  const assetsDir = fsHelpers.getFirstMatchingDirectory(targetDir, [
    'assets',
    'static',
  ]);
  const functionsTargetDir = path.join(functionsDir, namespace);
  const assetsTargetDir = path.join(assetsDir, namespace);

  if (functionsTargetDir !== functionsDir) {
    if (hasFilesOfType(files, 'functions')) {
      try {
        await mkdir(functionsTargetDir);
      } catch (err) {
        debug(err);
        throw new Error(
          `Template with name "${namespace}" already exists in "${functionsDir}"`
        );
      }

@twilio-labs/serverless-api

API-wrapper for the Twilio Serverless API

MIT
Latest version published 7 months ago

Package Health Score

78 / 100
Full package analysis