How to use the @now/build-utils.detectRoutes function in @now/build-utils

To help you get started, we’ve selected a few @now/build-utils 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 zeit / now / packages / now-cli / src / util / dev / server.ts View on Github external
tag: getDistTag(cliVersion) === 'canary' ? 'canary' : 'latest',
        functions: config.functions,
        ...(projectSettings ? { projectSettings } : {}),
      });

      if (errors) {
        this.output.error(errors[0].message);
        await this.exit();
      }

      if (warnings && warnings.length > 0) {
        warnings.forEach(warning => this.output.warn(warning.message));
      }

      if (builders) {
        const { defaultRoutes, error: routesError } = await detectRoutes(
          files,
          builders
        );

        config.builds = config.builds || [];
        config.builds.push(...builders);

        if (routesError) {
          this.output.error(routesError.message);
          await this.exit();
        } else {
          config.routes = config.routes || [];
          config.routes.push(...(defaultRoutes as RouteConfig[]));
        }
      }
    }
github zeit / now / packages / now-cli / src / util / dev / server.ts View on Github external
const { builders, warnings, errors } = await detectBuilders(files, pkg, {
        tag: getDistTag(cliVersion) === 'canary' ? 'canary' : 'latest',
      });

      if (errors) {
        this.output.error(errors[0].message);
        await this.exit();
      }

      if (warnings && warnings.length > 0) {
        warnings.forEach(warning => this.output.warn(warning.message));
      }

      if (builders) {
        const { defaultRoutes, error: routesError } = await detectRoutes(
          files,
          builders
        );

        config.builds = config.builds || [];
        config.builds.push(...builders);

        if (routesError) {
          this.output.error(routesError.message);
          await this.exit();
        } else {
          config.routes = config.routes || [];
          config.routes.push(...(defaultRoutes as RouteConfig[]));
        }
      }
    }
github zeit / now / src / util / dev / server.ts View on Github external
const files = allFiles.filter(this.filter);

      this.output.debug(
        `Found ${allFiles.length} and ` +
          `filtered out ${allFiles.length - files.length} files`
      );

      const { builders, errors } = await detectBuilders(files, pkg);

      if (errors) {
        this.output.error(errors[0].message);
        await this.exit();
      }

      if (builders) {
        const { defaultRoutes, error: routesError } = await detectRoutes(
          files,
          builders
        );

        config.builds = config.builds || [];
        config.builds.push(...builders);

        if (routesError) {
          this.output.error(routesError.message);
          await this.exit();
        } else {
          config.routes = config.routes || [];
          config.routes.push(...(defaultRoutes as RouteConfig[]));
        }
      }
    }