packages/okam-build/lib/processor/FileFactory.js
function createFile(fileInfo, rootDir) {
    let {path: relPath, fullPath, data, isVirtual, isScript, isStyle, isTemplate} = fileInfo;
    if (relPath && !fullPath) {
        fullPath = path.resolve(rootDir, relPath);
    }

    let extname = path.extname(fullPath).slice(1).toLowerCase();
    let vf = {
        processor: FILE_EXT_PROCESSOR[extname],
        dirname: path.dirname(fullPath),
        extname,
        fullPath,
        path: relPath || relative(fullPath, rootDir),
        rawContent: data,
        isVirtual,
        isScript: isScript == null ? isScriptType(extname) : isScript,
        isStyle: isStyle == null ? isStyleType(extname) : isStyle,
        isImg: isImgType(extname),
        isTpl: isTemplate == null ? isTplType(extname) : isTemplate,
        isJson: isJsonType(extname),
        addDeps,
        addSubFile,
        reset: resetFile,
        sourceMap: null
    };

    Object.defineProperties(vf, {
        stream: {
            get: getFileStream
        },
        content: {
            get: loadFileContent,
            set: updateFileContent
        }
    });

    return vf;
}
function createFile(fileInfo, rootDir) {
    let {path: relPath, fullPath, data, isVirtual, isScript, isStyle, isTemplate} = fileInfo;
    if (relPath && !fullPath) {
        fullPath = path.resolve(rootDir, relPath);
    }

    let extname = path.extname(fullPath).slice(1).toLowerCase();
    let vf = {
        processor: FILE_EXT_PROCESSOR[extname],
        dirname: path.dirname(fullPath),
        extname,
        fullPath,
        path: relPath || relative(fullPath, rootDir),
        rawContent: data,
        isVirtual,
        isScript: isScript == null ? isScriptType(extname) : isScript,
        isStyle: isStyle == null ? isStyleType(extname) : isStyle,
        isImg: isImgType(extname),
        isTpl: isTemplate == null ? isTplType(extname) : isTemplate,
        isJson: isJsonType(extname),
        addDeps,
        addSubFile,
        reset: resetFile,
        sourceMap: null
    };

    Object.defineProperties(vf, {
        stream: {
            get: getFileStream
        },
        content: {
            get: loadFileContent,
            set: updateFileContent
        }
    });

    return vf;
}
Create file info object

@param {Object} fileInfo the file to create
@param {string=} fileInfo.fullPath the file absolute path
@param {string=} fileInfo.path the relative path relative to rootDir
@param {boolean=} fileInfo.isVirtual whether a virtual file, optional, by default false
@param {*=} fileInfo.data the file content, optional
@param {string} rootDir the root directory
@return {Object}