How to use the @parcel/logger.error function in @parcel/logger

To help you get started, we’ve selected a few @parcel/logger 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 parcel-bundler / parcel / packages / core / parcel-bundler / src / Bundler.js View on Github external
// Unload any orphaned assets
      this.unloadOrphanedAssets();

      let buildTime = Date.now() - startTime;
      let time = prettifyTime(buildTime);
      logger.success(`Built in ${time}.`);
      if (!this.watcher) {
        bundleReport(this.mainBundle, this.options.detailedReport);
      }

      this.emit('bundled', this.mainBundle);
      return this.mainBundle;
    } catch (err) {
      this.error = err;

      logger.error(err);

      this.emit('buildError', err);

      if (this.hmr) {
        this.hmr.emitError(err);
      }

      if (this.options.throwErrors && !this.hmr) {
        throw err;
      } else if (!this.options.watch || !initialised) {
        await this.stop();
        process.exit(1);
      }
    } finally {
      this.pending = false;
      this.emit('buildEnd');
github parcel-bundler / parcel / src / core / core / src / Bundler.js View on Github external
// Unload any orphaned assets
      this.unloadOrphanedAssets();

      let buildTime = Date.now() - startTime;
      let time = prettifyTime(buildTime);
      logger.success(`Built in ${time}.`);
      if (!this.watcher) {
        bundleReport(this.mainBundle, this.options.detailedReport);
      }

      this.emit('bundled', this.mainBundle);
      return this.mainBundle;
    } catch (err) {
      this.error = err;

      logger.error(err);
      this.emit('buildError', err);

      if (this.hmr) {
        this.hmr.emitError(err);
      }

      if (process.env.NODE_ENV === 'production') {
        process.exitCode = 1;
      } else if (process.env.NODE_ENV === 'test' && !this.hmr) {
        throw err;
      }
    } finally {
      this.pending = false;
      this.emit('buildEnd');

      // If not in watch mode, stop the worker farm so we don't keep the process running.
github chrisdmacrae / parceleventy / lib / parcel / parcel-plugin-eleventy-sync / lib / Watcher.js View on Github external
async handleUnlink(path) {
        try {
            const isUnlinked = this.unlinked.has(path);

            if (!isUnlinked) {
                this.unlinked.add(path);
            }
        } catch (error) {
            logger.error(error);
        }
    }
github parcel-bundler / parcel / packages / reporters / dev-server / src / Server.js View on Github external
this.server.once('error', err => {
        logger.error(new Error(serverErrors(err, this.options.port)));
        reject(err);
      });
github parcel-bundler / parcel / packages / core / parcel-bundler / src / FSCache.js View on Github external
async write(filename, data) {
    try {
      await this.ensureDirExists();
      await this.writeDepMtimes(data);
      await fs.writeFile(this.getCacheFile(filename), JSON.stringify(data));
      this.invalidated.delete(filename);
    } catch (err) {
      logger.error(`Error writing to cache: ${err.message}`);
    }
  }
github parcel-bundler / parcel / packages / core / package-manager / src / Yarn.js View on Github external
.on('error', e => {
        logger.error(e, '@parcel/package-manager');
      })
      .on('data', (message: YarnStdOutMessage) => {
github chrisdmacrae / parceleventy / lib / parcel / parcel-plugin-eleventy-sync / lib / Watcher.js View on Github external
async loadConfig() {
        try {
            const asset = new Asset(path.resolve(this.options.rootDir, this.name), this.options);
            const config = await asset.getConfig(this.configFiles, {
                packageKey: this.packageKey
            });

            if (config) {
               return typeof config === "function" ? config() : config;
            }

            return {};
        } catch (error) {
            logger.error(error);
        }
    }
github chrisdmacrae / parceleventy / lib / parcel / parcel-plugin-eleventy-sync / lib / Watcher.js View on Github external
handleBuildStart() {
        try {
            const sourcePattern = path.join(this.options.eleventyDist, "**/*");
            const sourceFiles = glob.sync(sourcePattern);

            for (let file of this.unlinked) {
                const shouldDelete = sourceFiles.indexOf(file) === -1;
                const exists = fs.existsSync(file);

                if (shouldDelete && exists) {
                    this._delete(file);
                }
            }
        } catch (error) {
            logger.error(error);
        }
    }
github parcel-bundler / parcel / packages / core / cache / src / Cache.js View on Github external
async set(key: string, value: mixed) {
    try {
      let blobPath = this._getCachePath(key);
      let data = serialize(value);

      await this.fs.writeFile(blobPath, data);
      return key;
    } catch (err) {
      logger.error(err, '@parcel/cache');
    }
  }
}