How to use the canonical-path.dirname function in canonical-path

To help you get started, we’ve selected a few canonical-path 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 angular / angular / aio / tools / stackblitz-builder / builder.js View on Github external
_initConfigAndCollectFileNames(configFileName) {
    var configDir = path.dirname(configFileName);
    var configSrc = fs.readFileSync(configFileName, 'utf-8');
    try {
      var config = (configSrc && configSrc.trim().length) ? JSON.parse(configSrc) : {};
      config.basePath = configDir; // assumes 'stackblitz.json' is at `/src` level.
    } catch (e) {
      throw new Error(`Stackblitz config - unable to parse json file: ${configFileName}\n${e}`);
    }

    var defaultIncludes = ['**/*.ts', '**/*.js', '**/*.css', '**/*.html', '**/*.md', '**/*.json', '**/*.png', '**/*.svg'];
    var boilerplateIncludes = ['src/environments/*.*', 'angular.json', 'src/polyfills.ts'];
    if (config.files) {
      if (config.files.length > 0) {
        if (config.files[0].substr(0, 1) == '!') {
          config.files = defaultIncludes.concat(config.files);
        }
      }
github angular / dgeni-packages / links / services / getLinkInfo.js View on Github external
if ( !getLinkInfoImpl.useFirstAmbiguousLink && docs.length > 1 ) {

      linkInfo.valid = false;
      linkInfo.errorType = 'ambiguous';
      linkInfo.error = 'Ambiguous link: "' + url + '".\n' +
        docs.reduce(function(msg, doc) { return msg + '\n  "' + doc.id + '" ('+ doc.docType + ') : (' + doc.path + ' / ' + doc.fileInfo.relativePath + ')'; }, 'Matching docs: ');

    } else if ( docs.length >= 1 ) {

      linkInfo.url = docs[0].path;
      linkInfo.title = title || encodeCodeBlock(docs[0].name, true);
      linkInfo.type = 'doc';

      if ( getLinkInfoImpl.relativeLinks && currentDoc && currentDoc.path ) {
        var currentFolder = path.dirname(currentDoc.path);
        var docFolder = path.dirname(linkInfo.url);
        var relativeFolder = path.relative(path.join('/', currentFolder), path.join('/', docFolder));
        linkInfo.url = path.join(relativeFolder, path.basename(linkInfo.url));
        log.debug(currentDoc.path, docs[0].path, linkInfo.url);
      }

    } else if ( url.indexOf('#') > 0 ) {
      var pathAndHash = url.split('#');
      linkInfo = getLinkInfoImpl(pathAndHash[0], title, currentDoc);
      linkInfo.url = linkInfo.url + '#' + pathAndHash[1];
      return linkInfo;

    } else if ( url.indexOf('/') === -1 && url.indexOf('#') !== 0 ) {

      linkInfo.valid = false;
      linkInfo.errorType = 'missing';
github angular / angular / aio / tools / transforms / links-package / services / getLinkInfo.js View on Github external
if (!getLinkInfoImpl.useFirstAmbiguousLink && docs.length > 1) {
      linkInfo.valid = false;
      linkInfo.errorType = 'ambiguous';
      linkInfo.error = 'Ambiguous link: "' + url + '".\n' + docs.reduce(function(msg, doc) {
        return msg + '\n  "' + doc.id + '" (' + doc.docType + ') : (' + doc.path + ' / ' +
            doc.fileInfo.relativePath + ')';
      }, 'Matching docs: ');

    } else if (docs.length >= 1) {
      linkInfo.url = docs[0].path;
      linkInfo.title = title || docs[0].title || docs[0].name && encodeCodeBlock(docs[0].name, true);
      linkInfo.type = 'doc';

      if (getLinkInfoImpl.relativeLinks && currentDoc && currentDoc.path) {
        var currentFolder = path.dirname(currentDoc.path);
        var docFolder = path.dirname(linkInfo.url);
        var relativeFolder =
            path.relative(path.join('/', currentFolder), path.join('/', docFolder));
        linkInfo.url = path.join(relativeFolder, path.basename(linkInfo.url));
        log.debug(currentDoc.path, docs[0].path, linkInfo.url);
      }

    } else if (url.indexOf('#') > 0) {
      var pathAndHash = url.split('#');
      linkInfo = getLinkInfoImpl(pathAndHash[0], title, currentDoc);
      linkInfo.url = linkInfo.url + '#' + pathAndHash[1];
      return linkInfo;

    } else if (url.indexOf('/') === -1 && url.indexOf('#') !== 0) {
      linkInfo.valid = false;
      linkInfo.errorType = 'missing';
github angular / dgeni-packages / ngdoc / tag-defs / module.js View on Github external
defaultFn: function(doc) {
      if ( doc.area === 'api' && doc.docType !== 'overview' ) {
        return path.dirname(doc.fileInfo.relativePath).split('/')[0];
      }
    }
  };
github angular / material / docs / config / index.js View on Github external
getOutputPath: function(doc) {
      return path.join(
        'partials',
        path.dirname(doc.fileInfo.relativePath),
        doc.fileInfo.baseName) + '.html';
    }
  });
github angular / angular / packages / compiler-cli / src / ngcc / src / transform / utils.ts View on Github external
function getMarkerPath(packageJsonPath: string, format: string) {
  return resolve(dirname(packageJsonPath), `__modified_by_ngcc_for_${format}__`);
}
github cloudinary / cloudinary_angular / protractor.config.js View on Github external
function ensureDirectoryExistence(filePath) {
    var dirname = path.dirname(filePath);
    if (directoryExists(dirname)) {
      return true;
    }
    ensureDirectoryExistence(dirname);
    fs.mkdirSync(dirname);
  }
github DavidIsrawi / SummarizeMe / client / protractor.config.js View on Github external
function ensureDirectoryExistence(filePath) {
    var dirname = path.dirname(filePath);
    if (directoryExists(dirname)) {
      return true;
    }
    ensureDirectoryExistence(dirname);
    fs.mkdirSync(dirname);
  }
github angular / angular / packages / compiler-cli / src / ngcc / src / transform / utils.ts View on Github external
.map(packageJsonPath => {
            const entryPointPackageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
            const entryPointPath: string|undefined = entryPointPackageJson[format];
            if (!entryPointPath) {
              return undefined;
            }
            const dtsEntryPointPath = entryPointPackageJson.typings || entryPointPath;
            return new EntryPoint(dirname(packageJsonPath), entryPointPath, dtsEntryPointPath);
          })
          .filter(isDefined);

canonical-path

paths that always use forward slashes

MIT
Latest version published 5 years ago

Package Health Score

50 / 100
Full package analysis