How to use @istanbuljs/schema - 9 common examples

To help you get started, we’ve selected a few @istanbuljs/schema 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 istanbuljs / babel-plugin-istanbul / src / index.js View on Github external
memokey += memosep + opts.nycrcPath
  }

  /* execFileSync is expensive, avoid it if possible! */
  if (memoize.has(memokey)) {
    return memoize.get(memokey)
  }

  const result = JSON.parse(execFileSync(process.execPath, args))
  const error = result['load-nyc-config-sync-error']
  if (error) {
    throw new Error(error)
  }

  const config = {
    ...schema.defaults.babelPluginIstanbul,
    cwd,
    ...result
  }
  memoize.set(memokey, config)
  return config
}
github istanbuljs / istanbuljs / packages / istanbul-lib-instrument / src / read-coverage.js View on Github external
if (typeof code === 'object' && typeof code.type === 'string') {
        // Assume code is already a babel ast.
        return code;
    }

    if (typeof code !== 'string') {
        throw new Error('Code must be a string');
    }

    // Parse as leniently as possible
    return parse(code, {
        allowImportExportEverywhere: true,
        allowReturnOutsideFunction: true,
        allowSuperOutsideMethod: true,
        sourceType: 'script',
        plugins: defaults.instrumenter.parserPlugins
    });
}
github istanbuljs / babel-plugin-istanbul / src / index.js View on Github external
enter (path) {
          this.__dv__ = null
          this.nycConfig = findConfig(this.opts)
          const realPath = getRealpath(this.file.opts.filename)
          if (shouldSkip(realPath, this.nycConfig)) {
            return
          }
          let { inputSourceMap } = this.opts
          if (this.opts.useInlineSourceMaps !== false) {
            if (!inputSourceMap && this.file.inputMap) {
              inputSourceMap = this.file.inputMap.sourcemap
            }
          }
          const visitorOptions = {}
          Object.entries(schema.defaults.instrumentVisitor).forEach(([name, defaultValue]) => {
            if (name in this.nycConfig) {
              visitorOptions[name] = this.nycConfig[name]
            } else {
              visitorOptions[name] = schema.defaults.instrumentVisitor[name]
            }
          })
          this.__dv__ = programVisitor(t, realPath, {
            ...visitorOptions,
            inputSourceMap
          })
          this.__dv__.enter(path)
        },
        exit (path) {
github istanbuljs / istanbuljs / packages / nyc-config-typescript / index.js View on Github external
'use strict';

const { parserPlugins } = require('@istanbuljs/schema').defaults.nyc;

module.exports = {
    cache: false,
    parserPlugins: parserPlugins.concat('typescript')
};
github istanbuljs / babel-plugin-istanbul / src / index.js View on Github external
Object.entries(schema.defaults.instrumentVisitor).forEach(([name, defaultValue]) => {
            if (name in this.nycConfig) {
              visitorOptions[name] = this.nycConfig[name]
            } else {
              visitorOptions[name] = schema.defaults.instrumentVisitor[name]
            }
          })
          this.__dv__ = programVisitor(t, realPath, {
github istanbuljs / istanbuljs / packages / istanbul-lib-instrument / src / instrumenter.js View on Github external
constructor(opts = {}) {
        this.opts = {
            ...defaults.instrumenter,
            ...opts
        };
        this.fileCoverage = null;
        this.sourceMap = null;
    }
    /**
github istanbuljs / istanbuljs / packages / istanbul-lib-instrument / src / index.js View on Github external
/**
 * createInstrumenter creates a new instrumenter with the
 * supplied options.
 * @param {Object} opts - instrumenter options. See the documentation
 * for the Instrumenter class.
 */
function createInstrumenter(opts) {
    return new Instrumenter(opts);
}

export { createInstrumenter };
export { programVisitor };
export { readInitialCoverage };

export const defaultOpts = defaults.instrumenter;
github istanbuljs / istanbuljs / packages / istanbul-lib-instrument / src / visitor.js View on Github external
function programVisitor(types, sourceFilePath = 'unknown.js', opts = {}) {
    const T = types;
    opts = {
        ...defaults.instrumentVisitor,
        ...opts
    };
    const visitState = new VisitState(
        types,
        sourceFilePath,
        opts.inputSourceMap,
        opts.ignoreClassMethods
    );
    return {
        enter(path) {
            if (shouldIgnoreFile(path.find(p => p.isProgram()))) {
                return;
            }
            if (alreadyInstrumented(path, visitState)) {
                return;
            }
github istanbuljs / nyc / lib / commands / helpers.js View on Github external
setupOptions (yargs, command, cwd) {
    Object.entries(schema.nyc.properties).forEach(([name, setup]) => {
      if (blockOptions.includes(name)) {
        return
      }

      const option = {
        description: setup.description,
        default: setup.default,
        type: setup.type
      }

      if (name === 'cwd') {
        if (command !== null) {
          return
        }

        option.default = cwd

@istanbuljs/schema

Schemas describing various structures used by nyc and istanbuljs

MIT
Latest version published 4 years ago

Package Health Score

68 / 100
Full package analysis

Similar packages