How to use plugin-error - 10 common examples

To help you get started, we’ve selected a few plugin-error 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 wechat-miniprogram / miniprogram-i18n / packages / gulp-i18n-wxml / index.ts View on Github external
// TODO: read functionn name from options
  const transfomer = new TranslationFunctionTransformer(i18nFunctionName, wxsModuleName)
  if (!file.contents) {
    return cb(null, file)
  }
  try {
    const transformedContents = transfomer.transform(file.contents.toString('utf-8'))
    let relativeWxsPath = path.relative(path.dirname(file.path), wxsPath)
    if (process.platform === 'win32') {
      relativeWxsPath = relativeWxsPath.replace(/\\/g, '/')
    }
    const wxsTag = getWxsTag(relativeWxsPath, wxsModuleName)
    file.contents = Buffer.concat([Buffer.from(wxsTag), Buffer.from(transformedContents)])
  } catch (err) {
    console.log('error:', err)
    return cb(new PluginError(PLUGIN_NAME, err))
  }
  return cb(null, file)
})
github sun-zheng-an / gulp-shell / index.ts View on Github external
const normalizeCommands = (commands: string | string[]): string[] => {
  if (typeof commands === 'string') {
    commands = [commands]
  }

  if (!Array.isArray(commands)) {
    throw new PluginError(PLUGIN_NAME, 'Missing commands')
  }

  return commands
}
github Fitbit / fitbit-sdk-toolchain / src / compileTranslations.ts View on Github external
}

      if (file.isBuffer()) {
        try {
          const contents = file.contents.toString('utf-8');
          translations.loadLanguage(languageTag, contents);
          translationFiles.set(languageTag, file.clone({ contents: false }));
          return next();
        } catch (error) {
          next(
            new PluginError(PLUGIN_NAME, error, { fileName: file.relative }),
          );
        }
      } else {
        next(
          new PluginError(
            PLUGIN_NAME,
            file.isStream()
              ? 'Streaming mode is not supported.'
              : 'Internal error processing file.',
            { fileName: file.relative },
          ),
        );
        return;
      }
    },
github netlify-templates / victor-hugo / gulpfile.babel.js View on Github external
webpack(myConfig, (err, stats) => {
    if (err) throw new pluginError("webpack", err);
    log(`[webpack] ${stats.toString({
      colors: true,
      progress: true
    })}`);
    browserSync.reload();
    cb();
  });
});
github Fitbit / fitbit-sdk-toolchain / src / componentManifest.ts View on Github external
flush(done) {
      if (!companionEntryPoint) {
        return done(
          new PluginError(
            PLUGIN_NAME,
            'No entry point was generated for companion component',
          ),
        );
      }

      const manifest: CompanionManifest = {
        manifestVersion: 2,
        companion: { main: companionEntryPoint },
        ...makeCommonManifest({
          projectConfig,
          buildId,
          apiVersion: apiVersions(projectConfig).companionApi,
        }),
      };
github Fitbit / fitbit-sdk-toolchain / src / nativeComponents.ts View on Github external
function findSection(name: string) {
    const sectionName = `.${name}`;

    const sections = elfSections[sectionName];
    if (!sections) {
      throw new PluginError(PLUGIN_NAME, `ELF section '${name}' is missing`, {
        fileName: elfPath,
      });
    }

    if (sections.length > 1) {
      throw new PluginError(
        PLUGIN_NAME,
        `ELF section '${name}' is present more than once`,
        { fileName: elfPath },
      );
    }

    return sections[0].data;
  }
github jgable / gulp-cache / src / index.js View on Github external
signals.on('error', (err) => {
			next(new PluginError('gulp-cache', err));
		});
github Fitbit / fitbit-sdk-toolchain / src / componentManifest.ts View on Github external
transform(file: Vinyl, _, next) {
      const isEntryPoint: boolean | undefined = file.isEntryPoint;
      if (isEntryPoint) {
        if (file.componentType === ComponentType.COMPANION) {
          if (companionEntryPoint) {
            return next(
              new PluginError(
                PLUGIN_NAME,
                'Multiple entry points were generated for companion, only one is allowed',
              ),
            );
          }
          companionEntryPoint = normalizeToPOSIX(file.relative);
        } else if (file.componentType === ComponentType.SETTINGS) {
          if (settingsEntryPoint) {
            return next(
              new PluginError(
                PLUGIN_NAME,
                'Multiple entry points were generated for settings, only one is allowed',
              ),
            );
          }
          settingsEntryPoint = normalizeToPOSIX(file.relative);
github Fitbit / fitbit-sdk-toolchain / src / appPackageManifest.ts View on Github external
function throwDuplicateComponent(existingPath: string) {
      const componentType =
        bundleInfo.type === 'device'
          ? `${bundleInfo.type}/${bundleInfo.family}`
          : bundleInfo.type;
      throw new PluginError(
        PLUGIN_NAME,
        `Duplicate ${componentType} component bundles: ${file.relative} / ${existingPath}`,
      );
    }
github salesforce-ux / design-system / scripts / gulp / lint / validate-markup.js View on Github external
const flush = function(next) {
    const report = renderReport(fullReport, count);
    const json = JSON.stringify(report, null, 2);
    printToConsole(json, 'Full info in .reports/validate.json');
    if (report.total > 0) {
      throw new Error(
        new PluginError(
          'Style restrictions',
          `Encountered ${report.total} style restriction errors`,
          { showStack: false }
        )
      );
    }
    this.push(
      new Vinyl({
        path: 'validations.json',
        contents: Buffer.from(json)
      })
    );
    next();
  };

plugin-error

Error handling for Vinyl plugins.

MIT
Latest version published 2 years ago

Package Health Score

68 / 100
Full package analysis

Popular plugin-error functions