How to use canonical-path - 10 common examples

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
build() {
    this._checkForOutdatedConfig();

    // When testing it sometimes helps to look a just one example directory like so:
    // var stackblitzPaths = path.join(this.basePath, '**/testing/*stackblitz.json');
    var stackblitzPaths = path.join(this.basePath, '**/*stackblitz.json');
    var fileNames = globby.sync(stackblitzPaths, { ignore: ['**/node_modules/**'] });
    fileNames.forEach((configFileName) => {
      try {
        // console.log('***'+configFileName)
        this._buildStackblitzFrom(configFileName);
      } catch (e) {
        console.log(e);
      }
    });
  }
github angular / angular / aio / tools / stackblitz-builder / builder.js View on Github external
var extn = path.extname(fileName);
      if (extn == '.png') {
        content = this._encodeBase64(fileName);
        fileName = fileName.substr(0, fileName.length - 4) + '.base64.png'
      } else {
        content = fs.readFileSync(fileName, 'utf-8');
      }

      if (extn == '.js' || extn == '.ts' || extn == '.css') {
        content = content + this.copyrights.jsCss;
      } else if (extn == '.html') {
        content = content + this.copyrights.html;
      }
      // var escapedValue = escapeHtml(content);

      var relativeFileName = path.relative(config.basePath, fileName);

      // Is the main a custom index-xxx.html file? Rename it
      if (relativeFileName == config.main) {
        relativeFileName = 'src/index.html';
      }

      // A custom main.ts file? Rename it
      if (/src\/main[-.]\w+\.ts$/.test(relativeFileName)) {
        relativeFileName = 'src/main.ts'
      }

      if (relativeFileName == 'index.html') {
        if (config.description == null) {
          // set config.description to title from index.html
          var matches = /<title>(.*)&lt;\/title&gt;/.exec(content);
          if (matches) {</title>
github angular / dgeni / packages / angularjs / processors / examples-parse.js View on Github external
doc.content = doc.content.replace(EXAMPLE_REGEX, function processExample(match, attributeText, exampleText) {
        var example = extractAttributes(attributeText);
        example.files = extractFiles(exampleText);
        example.id = 'example-' + uniqueName(example.name || 'example');
        example.doc = doc;
        example.outputFolder = path.join(outputFolder, example.id);
        
        // store the example information for later
        examples.push(example);

        return generateExampleDirective(example);
      });
    });
github Famous / famous-angular / docs-generation / processors / create-folders.js View on Github external
create: function(config) {
		var currentVersion = config.get('currentVersion');

		var docsBase = path.join(config.get('basePath'), config.get('rendering.outputFolder'), 'docs');
		var versionDir = path.join(docsBase, currentVersion);

		// create the folders for the current version
		mkdirp.sync(versionDir);
	}
};
github ngrx / platform / projects / ngrx.io / tools / stackblitz-builder / builder.js View on Github external
_createPostData(config, configFileName) {
    var postData = {};

    // If `config.main` is specified, ensure that it points to an existing file.
    if (config.main && !this._existsSync(path.join(config.basePath, config.main))) {
      throw Error(`The main file ('${config.main}') specified in '${configFileName}' does not exist.`);
    }

    config.fileNames.forEach((fileName) => {
      var content;
      var extn = path.extname(fileName);
      if (extn == '.png') {
        content = this._encodeBase64(fileName);
        fileName = fileName.substr(0, fileName.length - 4) + '.base64.png'
      } else {
        content = fs.readFileSync(fileName, 'utf-8');
      }

      if (extn == '.js' || extn == '.ts' || extn == '.css') {
        content = content + this.copyrights.jsCss;
      } else if (extn == '.html') {
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 / 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)) {
github angular / angular / aio / tools / ng-packages-installer / index.js View on Github external
_printWarning() {
    const relativeScriptPath = path.relative('.', __filename.replace(/\.js$/, ''));
    const absoluteProjectDir = path.resolve(this.projectDir);
    const restoreCmd = `node ${relativeScriptPath} restore ${absoluteProjectDir}`;

    // Log a warning.
    this._warn([
      `The project at "${absoluteProjectDir}" is running against the local Angular build.`,
      '',
      'To restore the npm packages run:',
      '',
      `  "${restoreCmd}"`,
    ].join('\n'));
  }
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);

canonical-path

paths that always use forward slashes

MIT
Latest version published 6 years ago

Package Health Score

50 / 100
Full package analysis