How to use the @now/build-utils.detectBuilders 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 / src / util / dev / server.ts View on Github external
} else {
        throw err;
      }
    }

    // no builds -> zero config
    if (!config.builds || config.builds.length === 0) {
      const allFiles = await getAllProjectFiles(this.cwd, this.output);
      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) {
github zeit / now / packages / now-cli / src / util / dev / server.ts View on Github external
} else {
        throw err;
      }
    }

    // no builds -> zero config
    if (!config.builds || config.builds.length === 0) {
      const allFiles = await getAllProjectFiles(this.cwd, this.output);
      const files = allFiles.filter(this.filter);

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

      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
github zeit / now / packages / now-cli / src / util / dev / server.ts View on Github external
await this.validateNowConfig(config);
    const { error: routeError, routes: maybeRoutes } = getTransformedRoutes({
      nowConfig: config,
    });
    if (routeError) {
      this.output.error(routeError.message);
      await this.exit();
    }
    config.routes = maybeRoutes || [];

    // no builds -> zero config
    if (!config.builds || config.builds.length === 0) {
      const { projectSettings } = config;

      const { builders, warnings, errors } = await detectBuilders(files, pkg, {
        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(