---- /*

Write the separate vendor file, then proceed with bundling
490165
function writeVendorFileThenBundle () {
    const vendorDestPath = path.join(opts.rootDir, outputOpts.dir, outputOpts.vendor)
    const outStream = fs.createWriteStream(vendorDestPath)

    var b = getBrowserifyInstance({
      inc: opts.inc,
      cacheFile: opts.cacheFile
    })

    // add vendor files to the bundle
    b.require(opts.vendor)

    const startTime = Date.now()
    const bStream = b.bundle()

    multistream(vendorFiles.map(createReadStream).concat(bStream))
      .pipe(outStream)
      .on('error', (err) => console.error(err))
      .on('close', function () {
        const endTime = Date.now()
        const delta = endTime - startTime

        console.error(
          '[vendor] written to %s (%s seconds)',
          vendorDestPath, (delta / 1000).toFixed(2)
        )

        bundle()
      })
  }
980054
def write_merged_lockfiles(without: [])
      unless external_lockfile?
        copy_bundler_env
        return
      end

      # handle external lockfile
      Tempfile.open(".appbundler-gemfile", app_dir) do |t|
        t.puts "source 'https://rubygems.org'"

        locked_gems = {}

        gemfile_lock_specs.each do |s|
          # next if SHITLIST.include?(s.name)
          spec = safe_resolve_local_gem(s)
          next if spec.nil?

          case s.source
          when Bundler::Source::Path
            locked_gems[spec.name] = %Q{gem "#{spec.name}", path: "#{spec.gem_dir}"}
          when Bundler::Source::Rubygems
            # FIXME: should add the spec.version as a gem requirement below
            locked_gems[spec.name] = %Q{gem "#{spec.name}", "= #{spec.version}"}
          when Bundler::Source::Git
            raise "FIXME: appbundler needs a patch to support Git gems"
          else
            raise "appbundler doens't know this source type"
          end
        end

        seen_gems = {}

        t.puts "# GEMS FROM GEMFILE:"

        requested_dependencies(without).each do |dep|
          next if SHITLIST.include?(dep.name)
          if locked_gems[dep.name]
            t.puts locked_gems[dep.name]
          else
            string = %Q{gem "#{dep.name}", #{requirement_to_str(dep.requirement)}}
            string << %Q{, platform: #{dep.platforms}} unless dep.platforms.empty?
            t.puts string
          end
          seen_gems[dep.name] = true
        end

        t.puts "# GEMS FROM LOCKFILE: "

        locked_gems.each do |name, line|
          next if SHITLIST.include?(name)
          next if seen_gems[name]
          t.puts line
        end

        t.close
        puts IO.read(t.path) # debugging
        Dir.chdir(app_dir) do
          FileUtils.rm_f "#{app_dir}/Gemfile.lock"
          Bundler.with_clean_env do
            so = Mixlib::ShellOut.new("bundle lock", env: { "BUNDLE_GEMFILE" => t.path })
            so.run_command
            so.error!
          end
          FileUtils.mv t.path, "#{app_dir}/Gemfile"
        end
      end
      "#{app_dir}/Gemfile"
    end
1320589
function write(description, options, callback) {
  var file = vfile(description)

  // Weird, right? Otherwise `fs` doesn’t accept it.
  if (!callback && typeof options === 'function') {
    callback = options
    options = undefined
  }

  if (!callback) {
    return new Promise(executor)
  }

  executor(resolve, callback)

  function resolve(result) {
    callback(null, result)
  }

  function executor(resolve, reject) {
    var fp

    try {
      fp = path.resolve(file.cwd, file.path)
    } catch (error) {
      return reject(error)
    }

    fs.writeFile(fp, file.contents || '', options, done)

    function done(error) {
      if (error) {
        reject(error)
      } else {
        resolve()
      }
    }
  }
}
830740
void writeJsFileToJsDir(TypeElement element, ElementVisitor visitor, String packagePath, String fn, String dir) {
		if (null != dir) {
			try (Writer w = fws.getFileObjectWriter(dir + File.separatorChar + "srvs", packagePath + "." + fn)) {
				messager.printMessage(Diagnostic.Kind.MANDATORY_WARNING, " javascript generation class : " + element + " to : " + dir);
				element.accept(visitor, w);
			} catch (IOException ioe) {
				messager.printMessage(Diagnostic.Kind.MANDATORY_WARNING, " FAILED TO CREATE : " + packagePath + "." + fn);
			}
		}
	}
921762
function cmdUpdate($v, $arg)
	{
		$report = [];
		$vendors = scandir(self::$vendorDir); //.php/Composer

		foreach($vendors as $vendor){
            		$vendorPath = self::$vendorDir.'/'.$vendor;

            		if ($vendor == '.' || $vendor == '..' || !is_dir($vendorPath)) {
                		continue;
            		}

            		$vendorFiles = scandir($vendorPath); //.php/Composer/devbr

			//varre todos os componentes "DEVBR"
			foreach ($vendorFiles as $componente) {
                		$componentePath = "$vendorPath/$componente"; //.php/Composer/devbr/html

				if ($componente == '.' || $componente == '..' || !is_dir($componentePath)) {
					continue;
				}

				if (is_dir("$componentePath/Config")) {
					//Coping all files (and directorys) in /Config
					$copy = static::copyDirectoryContents("$componentePath/Config", self::$configDir, false, self::$configDir);
                    			$report["$vendor/$componente"] = $copy;

					//Return to application installer
					echo "\n - Install $vendor/$componente:";

                    			//Copied
                    			$copied = count($copy['copied']);
                    			if ($copied > 0) {
                        			echo " $copied file(s) copied.";
                    			}
                    
                    			//Permissions 
                    			if (isset($copy['error']['permission'])) {
                        			echo " I can't allow to copy one or more files.";
                    			}

                    			//Files exists
                    			if (isset($copy['error']['overwrite'])) {
                        			echo ' '.($copied > 0 ? 'Some f':'F').'iles already existed.';                                
                    			}
				}
			}
            echo "\n";
		}

		//Saving a log file
		file_put_contents(self::$configDir.'/install.log.json', json_encode($report, JSON_PRETTY_PRINT));
	}
1215210
def cleanup_bundle():
    
    paths = ['./vendored', './bundle.zip']
    for path in paths:
        if os.path.exists(path):
            log.debug("Deleting %s..." % path)
            if os.path.isdir(path):
                shutil.rmtree(path)
            else:
                os.remove(path)
1364169
def vendor!(dir = nil, force = false)
      resolve! if paths.empty?
      dir ||= options[:vendor_dir]
      dir ||= 'vendor' # default
      logger.debug "Vendoring #{paths.length} files to #{dir}"
      paths.collect {|n, p| p }.flatten.each do |path, name, version|
        if index.in_jimhome?(path)
          Jim::Installer.new(path, dir, :shallow => true, :force => force).install
        end
      end
      dir
    end
149640
function saveAsIndexedFile(bundle, options, log) {
  const {
    bundleOutput,
    bundleEncoding: encoding,
    sourcemapOutput
  } = options;

  log('start');
  const {startupModules, lazyModules, groups} = bundle.getUnbundle();
  log('finish');

  const moduleGroups = ModuleGroups(groups, lazyModules);
  const startupCode = joinModules(startupModules);

  log('Writing unbundle output to:', bundleOutput);
  const writeUnbundle = writeBuffers(
    fs.createWriteStream(bundleOutput),
    buildTableAndContents(startupCode, lazyModules, moduleGroups, encoding)
  ).then(() => log('Done writing unbundle output'));

  const sourceMap =
    buildSourceMapWithMetaData({startupModules, lazyModules, moduleGroups});

  return Promise.all([
    writeUnbundle,
    writeSourceMap(sourcemapOutput, JSON.stringify(sourceMap), log),
  ]);
}
1323662
@Override
	public void processBundles(GlobalPostProcessingContext ctx, List<JoinableResourceBundle> bundles) {

		if (ctx.hasBundleToBeProcessed()) {
			String workingDir = ctx.getRsReaderHandler().getWorkingDirectory();

			if (srcDir == null || destDir == null || tempDir == null || srcZipDir == null || destZipDir == null) {
				srcDir = ctx.getBundleHandler().getBundleTextDirPath();
				srcZipDir = ctx.getBundleHandler().getBundleZipDirPath();
				destDir = workingDir + GOOGLE_CLOSURE_RESULT_TEXT_DIR;
				destZipDir = workingDir + GOOGLE_CLOSURE_RESULT_ZIP_DIR;
				tempDir = workingDir + GOOGLE_CLOSURE_TEMP_DIR;
			}

			// Create result directory
			File dir = new File(destDir);
			if (!dir.exists() && !dir.mkdirs()) {
				throw new BundlingProcessException("Impossible to create temporary directory :" + destDir);
			}

			// Create result directory
			dir = new File(destZipDir);
			if (!dir.exists() && !dir.mkdirs()) {
				throw new BundlingProcessException("Impossible to create temporary directory :" + destZipDir);
			}

			// Create temporary directory
			dir = new File(tempDir);
			if (!dir.exists() && !dir.mkdirs()) {
				throw new BundlingProcessException("Impossible to create temporary directory :" + tempDir);
			}

			// Copy the bundle files in a temp directory
			try {
				FileUtils.copyDirectory(new File(srcDir), new File(tempDir));

				Map<String, String> resultBundleMapping = new HashMap<>();
				JawrClosureCommandLineRunner cmdRunner = new JawrClosureCommandLineRunner(ctx, bundles,
						resultBundleMapping);
				cmdRunner.doRun();
				// Copy compiled bundles
				FileUtils.copyDirectory(new File(destDir), new File(srcDir));

				// Copy zipped compiled bundles
				FileUtils.copyDirectory(new File(destZipDir), new File(srcZipDir));

			} catch (Exception e) {

				throw new BundlingProcessException(e);
			}
		}
	}
261321
function saveAsIndexedFile(
  bundle: RamBundleInfo,
  options: OutputOptions,
  log: (...args: Array<string>) => void,
): Promise<mixed> {
  const {
    bundleOutput,
    bundleEncoding: encoding,
    sourcemapOutput,
    sourcemapSourcesRoot,
  } = options;

  log('start');
  const {startupModules, lazyModules, groups} = bundle;
  log('finish');

  const moduleGroups = createModuleGroups(groups, lazyModules);
  const startupCode = joinModules(startupModules);

  log('Writing unbundle output to:', bundleOutput);
  const writeUnbundle = writeBuffers(
    fs.createWriteStream(bundleOutput),
    buildTableAndContents(startupCode, lazyModules, moduleGroups, encoding),
  ).then(() => log('Done writing unbundle output'));

  if (sourcemapOutput) {
    const sourceMap = buildSourcemapWithMetadata({
      startupModules: startupModules.concat(),
      lazyModules: lazyModules.concat(),
      moduleGroups,
      fixWrapperOffset: true,
    });
    if (sourcemapSourcesRoot !== undefined) {
      relativizeSourceMapInline(sourceMap, sourcemapSourcesRoot);
    }

    const wroteSourceMap = writeSourceMap(
      sourcemapOutput,
      JSON.stringify(sourceMap),
      log,
    );

    return Promise.all([writeUnbundle, wroteSourceMap]);
  } else {
    return writeUnbundle;
  }
}
967950
function writePackageJson (devDependencies) {
  debug('input devDependencies: %o', devDependencies)

  if (!lodash.isPlainObject(devDependencies)) {
    debug('devDependencies isn\'t plain object, return')
    // 不报错
    return Promise.resolve()
  }

  const baseDir = getBaseDir()
  const pkgPath = path.join(baseDir, 'package.json')

  debug(`package.json: ${pkgPath}`)

  if (!fs.existsSync(pkgPath)) {
    debug(`file not exists: ${pkgPath}, return`)
    return Promise.resolve()
  }

  let content

  try {
    content = JSON.parse(fs.readFileSync(pkgPath))
  } catch (error) {
    debug('parse package.json error')
    return Promise.resolve()
  }

  content.devDependencies = sort(Object.assign(
    {},
    content.devDependencies || {},
    devDependencies
  ))

  return writeJsonFile(pkgPath, content, {
    detectIndent: true
  })
}
134565
function BundleFile() {

  var location = getTempFileName('.browserify.js');

  function write(content) {
    fs.writeFileSync(location, content);
  }

  function exists() {
    return fs.existsSync(location);
  }

  function remove() {
    if (exists()) {
      fs.unlinkSync(location);
    }
  }

  function touch() {
    if (!exists()) {
      write('');
    }
  }


  // API

  this.touch = touch;

  this.update = write;
  this.remove = remove;

  this.location = location;
}
340046
@Override
	public void writeBundleTo(String bundlePath, Writer writer) throws ResourceNotFoundException {
		
		String text = (String) cacheMgr.get(TEXT_CACHE_PREFIX + bundlePath);
		try {
			// If it's not cached yet
			if (null == text) {
				String charsetName = rsHandler.getConfig().getResourceCharset().name();
				ByteArrayOutputStream baOs = new ByteArrayOutputStream();
				WritableByteChannel wrChannel = Channels.newChannel(baOs);
				Writer tempWriter = Channels.newWriter(wrChannel, charsetName);
				rsHandler.writeBundleTo(bundlePath, tempWriter);
				text = baOs.toString(charsetName);
				cacheMgr.put(TEXT_CACHE_PREFIX + bundlePath, text);
			}

			// Write the text to the outputstream
			writer.write(text);
			writer.flush();

		} catch (IOException e) {
			throw new BundlingProcessException("Unexpected IOException writing bundle[" + bundlePath + "]", e);
		}finally {
			IOUtils.close(writer);
		}
	}
735925
function(callback) {
        var data = JSON.parse(JSON.stringify(self.projectData, null, 4));
        data.bundles[self.bundle] = {
            "comment" : "Your comment goes here.",
            "tag" : "001",
            "src" : "src/" + bundle,
            "release" : {
                "version" : "0.0.1",
                "link" : "bundles/"+ bundle
            }
        };
        try {
            fs.writeFileSync(self.project, JSON.stringify(data, null, 4));
            callback(false, data)
        } catch (err) {
            callback(err, undefined)
        }
    }
425864
async function build( inputOpts, outputOpts ) {

  // create a bundle
  const bundle = await rollup.rollup( inputOpts );

  // generate code and a sourcemap
  const { code, map } = await bundle.generate( outputOpts );

  console.log( 'Writing file: ' + outputOpts.file );
  writeFile( outputOpts.file, code );

  console.log( 'Generated bundle: ', bundle.getTimings()[ '# GENERATE' ] );

}
535728
function writeSpecFile(grunt, options, filesToPack) {
	return function(callback) {
		try {
			var specPath = path.join(options.destination, specFolder);
			options.files = filesToPack;
			var pkg = grunt.file.readJSON('package.json');
			grunt.util._.defaults(options, pkg);
			
			options.specFilepath = path.join(specPath, options.name + '.spec');
			spec(options, callback);
		} catch(e) {
			callback(e);
		}
	};
}
913377
function writeLicensesFile(rootDir) {

    var licenses = checkLicenses(rootDir),
        licensesFileContent = "LICENSES " + "\n \n";

    _(licenses).each(function(licenseData, licenseName) {

        licensesFileContent += licenseName + " : ";

        if(licenseData.isMIT) {
            licensesFileContent += "MIT";
        }
        else {
            licensesFileContent += "Unknown License";
        }

        licensesFileContent += "\n \n";

        if(licenseData.content) {
            licensesFileContent += licenseData.content + "\n \n";
        }

    });

    fs.writeFileSync(rootDir + "/LICENSES", licensesFileContent, "utf-8");
}