How to use the canonical-path.basename 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 / plunker-builder / builder.js View on Github external
_buildPlunkerFrom(configFileName) {
    // replace ending 'plnkr.json' with 'plnkr.no-link.html' to create output file name;
    var outputFileName = `${this.options.plunkerFileName}.no-link.html`;
    outputFileName = configFileName.replace(/plnkr\.json$/, outputFileName);
    var altFileName;
    if (this.destPath && this.destPath.length > 0) {
      var partPath = path.dirname(path.relative(this.basePath, outputFileName));
      var altFileName = path.join(this.destPath, partPath, path.basename(outputFileName)).replace('.no-link.', '.');
    }
    try {
      var config = this._initConfigAndCollectFileNames(configFileName);
      var postData = this._createPostData(config);
      this._addPlunkerFiles(postData);
      var html = this._createPlunkerHtml(config, postData);
      if (this.options.writeNoLink) {
        fs.writeFileSync(outputFileName, html, 'utf-8');
      }
      if (altFileName) {
        var altDirName = path.dirname(altFileName);
        fs.ensureDirSync(altDirName);
        fs.writeFileSync(altFileName, html, 'utf-8');
      }
    } catch (e) {
      // if we fail delete the outputFile if it exists because it is an old one.
github angular / angular / aio / tools / stackblitz-builder / builder.js View on Github external
_buildStackblitzFrom(configFileName) {
    // replace ending 'stackblitz.json' with 'stackblitz.no-link.html' to create output file name;
    var outputFileName = `stackblitz.no-link.html`;
    outputFileName = configFileName.replace(/stackblitz\.json$/, outputFileName);
    var altFileName;
    if (this.destPath && this.destPath.length > 0) {
      var partPath = path.dirname(path.relative(this.basePath, outputFileName));
      var altFileName = path.join(this.destPath, partPath, path.basename(outputFileName)).replace('.no-link.', '.');
    }
    try {
      var config = this._initConfigAndCollectFileNames(configFileName);
      var postData = this._createPostData(config, configFileName);
      this._addDependencies(postData);
      var html = this._createStackblitzHtml(config, postData);
      fs.writeFileSync(outputFileName, html, 'utf-8');
      if (altFileName) {
        var altDirName = path.dirname(altFileName);
        fs.ensureDirSync(altDirName);
        fs.writeFileSync(altFileName, html, 'utf-8');
      }
    } catch (e) {
      // if we fail delete the outputFile if it exists because it is an old one.
      if (this._existsSync(outputFileName)) {
        fs.unlinkSync(outputFileName);
github angular / dgeni-packages / ngdoc / services / partial-names.js View on Github external
linkInfo.type = 'doc';

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

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

    linkInfo.valid = false;
    linkInfo.error = 'Invalid link (does not match any doc): "' + url + '"';

  } else {

    linkInfo.title = title || (( url.indexOf('#') === 0 ) ? url.substring(1) : path.basename(url, '.html'));

  }

  return linkInfo;
};
github angular / angular / docs / links-package / services / getLinkInfo.js View on Github external
} 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';
      linkInfo.error = 'Invalid link (does not match any doc): "' + url + '"';

    } else {

      linkInfo.title = title || (( url.indexOf('#') === 0 ) ? url.substring(1) : path.basename(url, '.html'));

    }

    return linkInfo;
  };
};
github angular / dgeni-packages / jsdoc / file-readers / jsdoc.spec.js View on Github external
var createFileInfo = function(file, content, basePath) {
    return {
      fileReader: fileReader.name,
      filePath: file,
      baseName: path.basename(file, path.extname(file)),
      extension: path.extname(file).replace(/^\./, ''),
      basePath: basePath,
      relativePath: path.relative(basePath, file),
      content: content
    };
  };
github angular / dgeni / lib / ngdoc-parser / ngdoc-plugins / calculate-id.js View on Github external
after: function idFromName(doc) {

    if ( doc.fileType === 'js' ) {

      var module = doc.module ? (doc.module + '.') : '';
      var type = (doc.ngdoc === 'directive' || doc.ngdoc === 'filter' || doc.ngdoc === 'global' ) ? doc.ngdoc + ':' : '';
    
      doc.id = doc.id || ('module:' + module + type + doc.name);

    } else {

      doc.id = doc.id || doc.name || path.basename(doc.file, '.' + doc.fileType);

    }
  }
};
github angular / dgeni / packages / jsdoc / processors / doc-extractor.js View on Github external
_.forEach(docs, function(doc) {
                doc.fileName = path.basename(doc.file, '.'+doc.fileType);
              });
github angular / angular / docs / typescript-package / services / tsParser / getFileInfo.js View on Github external
return function (symbol, basePath) {
    var fileName = ts.getSourceFileOfNode(symbol.declarations[0]).fileName;

    var file = path.resolve(basePath, fileName);
    var fileInfo = {
      filePath: file,
      baseName: path.basename(file, path.extname(file)),
      extension: path.extname(file).replace(/^\./, ''),
      basePath: basePath,
      relativePath: fileName,
      projectRelativePath: fileName
    };
    return fileInfo;
  };
};
github angular / dgeni-packages / jsdoc / processors / extractJSDocComments.spec.js View on Github external
var createFileInfo = function(file, content, basePath) {
    return {
      filePath: file,
      baseName: path.basename(file, path.extname(file)),
      extension: path.extname(file).replace(/^\./, ''),
      basePath: basePath,
      relativePath: path.relative(basePath, file),
      content: content,
      ast: jsParser(content),
    };
  };
github angular / angular / aio / tools / transforms / content-package / readers / content.spec.js View on Github external
var createFileInfo = function(file, content, basePath) {
    return {
      fileReader: fileReader.name,
      filePath: file,
      baseName: path.basename(file, path.extname(file)),
      extension: path.extname(file).replace(/^\./, ''),
      basePath: basePath,
      relativePath: path.relative(basePath, file),
      content: content
    };
  };

canonical-path

paths that always use forward slashes

MIT
Latest version published 6 years ago

Package Health Score

50 / 100
Full package analysis