parse .vue content to an object with all blocks' code
@param {string} filepath the path of .vue file

@return {Object} an object with all blocks' code
 
@file compile .vue to .js
@author JoeRay61(joeray199261@gmail.com)
547963
function getBlocks(filepath) {
    if (!filepath) {
        return;
    }
    var content = (0, _fs.readFileSync)(filepath, 'utf8');
    var result = (0, _vueTemplateCompiler.parseComponent)(content);
    var ret = {
        template: {
            code: result.template.content
        },
        script: {
            code: result.script.content
        },
        styles: []
    };
    result.styles.forEach(function (e, i) {
        ret.styles[i] = {
            code: e.content
        };
    });
    result.customBlocks.forEach(function (e, i) {
        var type = e.type;
        ret[type] = ret[type] || [];
        ret[type].push({
            code: e.content
        });
    });
    return ret;
}
415811
public function parseFile($filePath, array $vars = [])
    {
        if (is_file($filePath)) {
            return $this->parseString(file_get_contents($filePath), $vars);
        }

        // Try to find from filePaths
        if (count($this->filePaths)) {
            foreach ($this->filePaths as $fileDirectory) {
                if (is_file($fileDirectory . $filePath)) {
                    return $this->parseString(file_get_contents($fileDirectory . $filePath), $vars);
                    break;
                }
            }
        }

        return null;
    }
838051
function (filePath, callback) {
        fs.readFile(filePath, function (err, data) {
            if (err)
                return callback(err);
            var message = parse(data.toString());
            callback(null, message);
        })
    }
254469
function processJavaScriptFilePath(filePath: string, fileByteSize: number) {
      // If `all` was configured then we don't need to check for the Flow
      // header pragma.
      if (options.all) {
        filePaths.push(filePath);
        return;
      }
      // If we were rejected then we should not continue.
      if (rejected === true) {
        return;
      }
      // We are now waiting on this asynchronous task.
      waiting++;
      // Open the file path.
      fs.open(filePath, 'r', (error, file) => {
        if (error) {
          return reject(error);
        }
        // Get the smaller of our pragma chars constant and the file byte size.
        const bytes = Math.min(PRAGMA_BYTES, fileByteSize);
        // Create the buffer we will read to.
        const buffer = new Buffer(bytes);
        // Read a set number of bytes from the file.
        fs.read(file, buffer, 0, bytes, 0, error => {
          if (error) {
            return reject(error);
          }
          // If the buffer has the @flow pragma then add the file path to our
          // final file paths array.
          if (buffer.includes('@flow')) {
            filePaths.push(filePath);
          }
          // Close the file.
          fs.close(file, error => {
            if (error) {
              return reject(error);
            }
            // We are done with this async task
            done();
          });
        });
      });
    }
835954
function parseFile(fs, file, type) {
    var filepath = file.getPath();
    var parser = file.getParser();

    if (!parser) {
        return Promise.reject(
            error.FileNotParsableError({
                filename: filepath
            })
        );
    }

    return fs.readAsString(filepath)
    .then(function(content) {
        if (type === 'readme') {
            return parser.parseReadme(content);
        } else if (type === 'glossary') {
            return parser.parseGlossary(content);
        } else if (type === 'summary') {
            return parser.parseSummary(content);
        } else if (type === 'langs') {
            return parser.parseLanguages(content);
        } else {
            throw new Error('Parsing invalid type "' + type + '"');
        }
    })
    .then(function(result) {
        return [
            file,
            result
        ];
    });
}
795320
function tryParse(filePath: string, platforms: Set<string>): ?AssetPath {
  const result = parsePlatformFilePath(filePath, platforms);
  const {dirPath, baseName, platform, extension} = result;
  if (extension == null) {
    return null;
  }
  const {rootName, resolution} = parseBaseName(baseName);
  return {
    assetName: path.join(dirPath, `${rootName}.${extension}`),
    name: rootName,
    platform,
    resolution,
    type: extension,
  };
}
678181
function htmlToJsonController (fileContents, filePath, output, p) {

    var matches;
    var includePaths = false;

    while (matches = _DIRECTIVE_REGEX.exec(fileContents)) {

        var relPath     = path.dirname(filePath),
            fullPath    = path.join(relPath,  matches[3].replace(/['"]/g, '')).trim(),
            jsonVar     = matches[2],
            extension   = matches[3].split('.').pop();

        var fileMatches = [];

        if (p.includePaths) {

            if (typeof p.includePaths == "string") {
                // Arrayify the string
                includePaths = [params.includePaths];
            }else if (Array.isArray(p.includePaths)) {
                // Set this array to the includepaths
                includePaths = p.includePaths;
            }

            var includePath = '';

            for (var y = 0; y < includePaths.length; y++) {

                includePath = path.join(includePaths[y], matches[3].replace(/['"]/g, '')).trim();

                if (fs.existsSync(includePath)) {

                    var globResults = glob.sync(includePath, {mark: true});
                    fileMatches = fileMatches.concat(globResults);

                }

            }

        } else {

            var globResults = glob.sync(fullPath, {mark: true});
            fileMatches = fileMatches.concat(globResults);

        }

        try {

            fileMatches.forEach(function(value){

                var _inc = _parse(value);

                if (_inc.length > 0) {

                    var ind = (jsonVar.trim() == '*') ? indName(value) : jsonVar;
                    output[ind] = _inc;
                }
            })

        } catch (err) {
            console.log(err)
        }

    }
}
178258
function getFile(filepath) {
	var fileObj = {
			path: filepath,
			content: null
	};
    try {
        fs.accessSync(filepath, fs.F_OK);
    } catch(e) {
			console.log(e.message);
        return fileObj;
    }
		fileObj.content = fs.readFileSync(filepath, 'utf-8').trim();
		return fileObj;
}
937145
function readXmlAsJson(filePath) {
  var xmlData;
  var xmlParser;
  var parsedData;

  try {
    xmlData = fs.readFileSync(filePath, 'utf8');
    xmlParser = new xml2js.Parser();
    xmlParser.parseString(xmlData, function(err, data) {
      if (data) {
        parsedData = data;
      }
    });
  } catch (err) {}

  return parsedData;
}
753811
function readInlineContent(filepath, buildInfo, arrs, options) {
        if(!arrs) arrs = {};

        var content = '';
        var filecontent = '';
        if(buildInfo && buildInfo[filepath]) {
            var info = buildInfo[filepath];
            //如果 有处理md5,则使用md5版本
            if(info && info.path) {
                filepath = info.path;
                filecontent = info.content;
            }
        }
        var isjs = path.extname(filepath) == '.js';

        //如果已经处理过，则直接返回
        if(arrs[filepath]) {
            return isjs?'':arrs[filepath];
        }
         
        if(filecontent || fs.existsSync(filepath)) {
            
            //gutil.log(gutil.colors.blue('inline file:'), gutil.colors.green(filepath));
            filecontent = filecontent || fs.readFileSync(filepath, 'utf-8');
            //如果指定需要包含依赖
            if(isjs && options.config.includeModule) {
                //解析当前脚本依赖，把所有依赖全inline进页面
                var astModule = ast.parseFirst(filecontent);
                //如果包含依赖
                if(astModule && astModule.dependencies && astModule.dependencies.length) {
                    var dir = path.dirname(filepath);
                    for(var i=0;i<astModule.dependencies.length;i++) {
                        var id = astModule.dependencies[i];
                        //如果不是相对路径，则使用js的目标目录
                        if(id[0] != '/' && id[0] != '.') {
                            var p = path.resolve(options.jsDestPath, id);
                        }
                        else {
                            //相对当于前调用js的路径
                            var p = path.resolve(dir, id);
                        }

                        if(!path.extname(p)) p += '.js';
                       // console.log('inline module:' + p);
                        content += readInlineContent(p, buildInfo, arrs, options) + "\n";
                    }
                }
            }
            content += filecontent;
        }
        else {
            gutil.log(gutil.colors.red('warning[inline]:'), gutil.colors.yellow(pluginName + ": the file " + filepath + " is not exists"));
        }
        arrs[filepath] = isjs?1:content;//表示当前路径已inline过了，
        return content;
    }
1151685
function parseFile (filePath, fileContent) {
  let config = null
  const extension = path.extname(filePath)

  if (extension === '.yml' || extension === '.yaml') {
    config = yaml.safeLoad(replaceEnvironmentVariables(fileContent))
  } else if (extension === '.js') {
    config = require(path.resolve(filePath)) // eslint-disable-line
  } else if (extension === '.json') {
    config = JSON.parse(replaceEnvironmentVariables(fileContent))
  } else {
    throw new Error(`${extension} is not supported as configuration file`)
  }

  return config
}
927707
function(dirpath) {
    try {

      // Make the directory under the app
      if (dirpath !== '/') {
        FS.mkdirSync(Path.join('.', appPath, dirpath));
      }

      // Read the template directory
      var templateDir = Path.join(__dirname, '../template/app', dirpath);
      var files = FS.readdirSync(templateDir);
      files.forEach(function(file) {
        var fullFile = Path.join(templateDir, file);
        var stat = FS.statSync(fullFile);
        if (stat.isDirectory()) {
          // Go into it
          outputDir(Path.join(dirpath, file));
        }
        else {
          outputFile(dirpath, file);
        }
      });

    } catch(e) {
      logger.fatal('Template', 'Cannot process template directory: ' + dirpath + '. reason: ', e.toString());
      process.exit(1);
    }
  }
972241
function injectScripts(filePath) {
  var contents = String($.fs.readFileSync(filePath));
  var fileExt = $.path.extname(filePath).substr(1);
  var fileType = fileTypes[fileExt] || fileTypes['default'];
  var returnType = /\r\n/.test(contents) ? '\r\n' : '\n';

  var newContents = contents.replace(
    fileType.block,
    replaceIncludes(filePath, fileType, returnType)
  );

  if (contents !== newContents) {
    $.fs.writeFileSync(filePath, newContents);

    config.get('on-file-updated')(filePath);
  }
}
654726
function (filePath,predicate,offset) {
	this.filePath=filePath;
	this.file=fs.readFileSync(filePath).toString().split('\n');
	this.text='';
	this.found=-1;

	if(offset===undefined || offset===null || offset===''){
		offset=0;
	}


	//SEARCH
	for(var i=0;i<this.file.length;i++){
		if(this.file[i].search(predicate)>=0){
			this.found=i;
			break;
		}
	}

	if(this.found<0){
		console.log('Predicate NOT found!. File untouched.');
		return null;
	}

	this.found+=offset;

	return this;
}
352301
async function getCodepointsMap(filepath) {
  const content = await fsAsync.readFile(filepath)
  let codepointsMap

  try {
    codepointsMap = JSON.parse(content)
  } catch (e) {
    throw new ValidationError('Codepoints map is invalid JSON')
  }

  for (let propName in codepointsMap) {
    codepointsMap[propName] = Number.parseInt(codepointsMap[propName])
  }

  return codepointsMap
}
752021
function (filePath, model) {
            filePath = getFileWithExt(filePath);
            filePath = path.join(configure.partialViewDir, filePath);
            var partialTemp = saker.getView(filePath);
            try {
                var html = saker.compile(partialTemp, filePath).call({
                    layout: null
                }, model);
            } catch (err) {
                throw err;
            }
            return html;
        }
1119871
public static function parseFile ($filePath, $xmlValidationEnabled=true)
    {
        // Extract content first
        $fileContent = self::getXmlContentFromFile($filePath);

        // Validate
        if ($xmlValidationEnabled) {
            if (!self::validateXmlContent($fileContent)) {
                throw new Exception("XML validation against rua.xsd failed");
            }
        }

        // Parse
        return self::parseXmlContent($fileContent);
    }