JavaScript 文件添加缩进
179143
function addJSIndent(file, t) {
    var addIndent = '  ';
    var filepath = file.path.replace(/\\/g, '/');
    if (
      filepath.endsWith('/global/js/wrap_start.js') ||
      filepath.endsWith('/global/js/wrap_end.js')
    ) {
      addIndent = '';
    }

    if (addIndent !== '') {
      var fileLines = fs.readFileSync(file.path).toString().split('\n');
      var newFileContents = '';
      $.each(fileLines, function (i, fileLine) {
        newFileContents +=
          (fileLine ? addIndent : '') +
          fileLine +
          (i === fileLines.length ? '' : '\n');
      });

      file.contents = new Buffer(newFileContents);
    }
  }
155077
function _fillInputFile(element, value, next) {
        var onUploadDone = function (localPath) {
            element.type(localPath, next);
        };
        this.uploadFile(value, onUploadDone);
    }
130629
function( file ) {
                if ( !(file instanceof WUFile) ) {
    
                    if ( !(file instanceof File) ) {
                        if ( !this._ruid ) {
                            throw new Error('Can\'t add external files.');
                        }
                        file = new File( this._ruid, file );
                    }
    
                    file = new WUFile( file );
                }
    
                return file;
            }
398156
function combineFileContent(pkg, toMergeFiles, context) {
    var content = '';
    var has = [];
    var isPackBundles = !! pkg.isPackBundles;
    toMergeFiles.forEach(function (file) {
        has.push(file.id);
        if(isPackBundles){
            if(file.packBundlesTo){
                fis.log.error('file [%s] has packBundlesTo[%s],can not packBundles more than once!',file.id,pkg.id);
                return;
            }
            file.packBundlesTo = pkg.subpath;
        }
        // 把要合并的文件的依赖信息添加到打包文件里
        addDependenceResource(pkg, 'addLink', file.links,context);
        addDependenceResource(pkg, 'addRequire', file.requires,context);
        addDependenceResource(pkg, 'addAsyncRequire', file.asyncs,context);

        var c;
        if(!isPackBundles && file.packBundlesTo){
            //已经合并在Bundles里面的模块不用打包到pkg里面，只需要pathmap里设置为Bundles文件的moduleId即可
            c = '';
        }else{
            c = file.getContent();
        }

        
       /* if (c && file.isCssLike && file !== pkg) {
            c = updateCSSContentUrl(c, file, pkg, context);
        }*/

        if (c) {
            if (file.isCssLike) {
                c = c.replace(CSS_CHARSET_REGEXP, '');
            }

            /**
             * @event pack:file 触发打包事件
             */
            fis.emit('pack:file', {
                file: file,
                content: c,
                pkg: pkg
            });

            content += c + '\n';
        }
    });

    return {
        content: content,
        has: has
    };
}
1338034
function(file, mode, options) {
		mode = mode || "replace";
		const args = options ? [file, mode].concat(util.formatOptions(options)) : [file, mode];
		this.socket.command("loadfile", args);
	}
770447
function(path){
    var script = document.createElement( 'script' );
    script.type = 'text/javascript';
    script.src = path;
    $("head").append( script );
  }
817205
function watchOnFile(file, callback) {
  let lastIndex = 0
  let timer

  function read() {
    const stat = fs.statSync(file)

    if (stat.size !== lastIndex) {
      const fd = fs.openSync(file, 'r')
      const buffer = Buffer.alloc(stat.size - lastIndex)

      try {
        fs.readSync(fd, buffer, lastIndex, stat.size - lastIndex)
        const content = buffer.toString('utf8')
        lastIndex = stat.size

        callback(content)
      } catch (error) {
        // 从头读起
        lastIndex = 0
      }
    }

    timer = setTimeout(read, 200)
  }

  read()
  return function() {
    clearTimeout(timer)
  }
}
187652
function addAddedFileInnScript(key, path, dot_path){
			dot_path = dot_path || path;
			// checking if same file imported twice for same Class.
			if(!dot_path) return;
			var script = scriptArr[scriptArr.length - 1];
			if( !script ){
				return;
			}
			var arr = script[key] ||  (script[key] = []);
			if( arr.indexOf(dot_path) === -1 ) {
				arr.push(dot_path);
			}
			return true;
		}
888628
function add(el, fn){
  el.addEventListener('load', function(_, e){ fn(null, e); }, false);
  el.addEventListener('error', function(e){
    var err = new Error('script error "' + el.src + '"');
    err.event = e;
    fn(err);
  }, false);
}
19153
function addFiles(name) {
  const componentDir = `${packagesDir}/${name}`;
  const componentSrcDir = `${packagesDir}/${name}/src`;
  const componentStyleDir = `${packagesDir}/${name}/style`;
  const upperComponentName = getComponentName(name);
  /* eslint-disable-next-line */
  console.log(`Adding new component：${upperComponentName}`);

  if (!fs.existsSync(componentDir)) {
    fs.mkdirSync(componentDir);
    fs.mkdirSync(componentSrcDir);
    fs.mkdirSync(componentStyleDir);
  } else {
    /* eslint-disable-next-line */
    console.log(`${upperComponentName} already exists, please choose another name.`);
    process.exit(2);
  }
  addFilesToIndex(name);
}
1263958
function include( path, isFromInclude, dot_path ) {
			if(!path){
				return;
			}
			all_paths.push(path)
			if(isNode){
				require(path);
				listenFileChange(path);
				if(isFromInclude){
					fileLoadeManager.iamready(dot_path);
				}
				return;
			}
			if (fm.isConcatinated) {
				fileLoadeManager.iamready(dot_path);
				return;
			}

			if (!docHead) {
				docHead = document.getElementsByTagName("head")[0];
			}

			// isNonfm && fm.holdReady(true);
			var e = document.createElement("script");
			// onerror is not supported by IE so this will throw exception only for
			// non IE browsers.

			if(me.version){
				path += "?v=" + me.version;
			}
			e.onerror = onFileLoadError;
			if(isFromInclude){
				e.onload = function(){
					fileLoadeManager.iamready(dot_path);
					$(document).trigger('jsfm-iamready-'+ path.split("/").pop().replace(".js", ""), [path]);
				};
			}

			e.src = path;
			e.type = "text/javascript";
			docHead.appendChild(e);
		}
653946
protected function wizardAddFile()
    {
        $this->validatePrompt('path', $this->text('Path'), 'file');
        $this->validatePrompt('entity', $this->text('Entity'), 'file');
        $this->validatePrompt('entity_id', $this->text('Entity ID'), 'file', 0);
        $this->validatePrompt('title', $this->text('Title'), 'file', '');
        $this->validatePrompt('description', $this->text('Description'), 'file', '');
        $this->validatePrompt('weight', $this->text('Weight'), 'file', 0);

        $this->validateComponent('file');
        $this->addFile();
    }
1339072
function loadJSON (file, callback) {
  loadText(file, function (err, data) {
    if (err) {
      callback(err, null)
    } else {
      var json = null
      try {
        json = JSON.parse(data)
      } catch (e) {
        return callback(e, null)
      }
      callback(null, json)
    }
  })
}
1118398
function jsCompile(content, file)
{
  // make it as a child of this module
  // Would be nice to actually make it transparent
  // and pretend it to be child of the caller module
  // but there is no obvious way, yet
  var jsMod = new Module(file, module);

  // override parents to exclude configly from the chain
  // it's like this js file is included directly
  // from the file that included `configly`
  while (jsMod.parent
    && typeof jsMod.parent.id === 'string'
    && jsMod.parent.id.match(/\/node_modules\/configly\//)
    && jsMod.parent.parent) {
    /* istanbul ignore next */
    jsMod.parent = jsMod.parent.parent;
  }

  // generate node_modules paths for the file
  jsMod.paths = Module._nodeModulePaths(path.dirname(file));

  // execute the module
  jsMod._compile(content, file);
  // return just exported object
  return jsMod.exports;
}
828532
function createPackageFile(content) {
    // todo in the rootfolder
    createFile({
        name: constants.INCLUDE_FILE,
        source: `${JSON.stringify(content)}\n`,
    });
}
1346767
def addFile(self,file):
        
        mylambda= lambda adict : { key.upper() : mylambda(adict[key]) if isinstance(adict[key],dict) else adict[key] for key in adict.keys() }
        if file.endswith('.json') :
            with open(file, 'r') as f:
                fileContent = mylambda(json.load(f))

        elif file.endswith('.ini') :
            parser  = configparser.ConfigParser()
            parser.read(file)
            fileContent = { section : { conflist[0].upper() : conflist[1] for conflist in parser.items(section) } for section in parser.sections() }
        else :
            raise FileFormatException()

        self._config = {**self._config, **mylambda(fileContent)}
283659
function upload(filesPaths) {
  const promises = filesPaths.map((v, i) => {
    const file = fs.createReadStream(v)
    const formData = {
      projectName: 'FrontEndResource',
      files: [file],
      path: 'frontend',
      usrName: '飞鱼籽',
    };
    return new Promise((resolve, reject) =>
      request.post({
        url: 'http://upload.2dfire-daily.com/upfileandlist',
        formData,
      }, function (error, response, body) {
        if (!error) {
          if (response.statusCode == 200) {
            try {
              const obj = JSON.parse(body)
              resolve({ file: v, response: obj })
              // console.log('success');
            } catch (error) {
              console.error(error);
            }
          } else {
            console.error('upload failed:', response.statusCode);
            reject()
          }
        } else {
          console.error('upload failed:', err);
          reject()
        }
      })
    )
  })

  return Promise.all(promises)
    .then((posts) => posts)
    .catch((e) => { console.error(e) });
}