Copies static files such as robots.txt, favicon.ico to the
output (build) folder.
960393
async function copy() {
  await makeDir('build');
  await Promise.all([
    writeFile(
      'build/package.json',
      JSON.stringify(
        {
          private: true,
          engines: pkg.engines,
          dependencies: pkg.dependencies,
          scripts: {
            start: 'node server.js',
          },
        },
        null,
        2,
      ),
    ),
    copyFile('LICENSE.txt', 'build/LICENSE.txt'),
    copyFile('yarn.lock', 'build/yarn.lock'),
    copyDir('public', 'build/public'),
  ]);

  if (process.argv.includes('--watch')) {
    const watcher = chokidar.watch(['public/**/*'], { ignoreInitial: true });

    watcher.on('all', async (event, filePath) => {
      const start = new Date();
      const src = path.relative('./', filePath);
      const dist = path.join(
        'build/',
        src.startsWith('src') ? path.relative('src', src) : src,
      );
      switch (event) {
        case 'add':
        case 'change':
          await makeDir(path.dirname(dist));
          await copyFile(filePath, dist);
          break;
        case 'unlink':
        case 'unlinkDir':
          cleanDir(dist, { nosort: true, dot: true });
          break;
        default:
          return;
      }
      const end = new Date();
      const time = end.getTime() - start.getTime();
      console.info(`[${format(end)}] ${event} '${dist}' after ${time} ms`);
    });
  }
}
783306
def make_app(httpd_config):
    
    #mimetypes.add_type('image/vnd.microsoft.icon', '.ico')

    # Default paths to serve static file from
    htdocs_paths = [
        os.path.realpath(os.path.join(config.config_dir, "htdocs")),
        os.path.join(os.path.dirname(config.__file__), "data", "htdocs"),
    ]

    return (Router()
        .add_route("/", controller=redirect, to="/static/index.html")
        .add_route("/favicon.ico", controller=redirect, to="/static/favicon.ico")
        .add_route("/static/{filepath:.+}", controller=StaticFolders(htdocs_paths))
        .add_route("/json/{action}", controller=JsonController(**httpd_config.json))
    )
1149877
def _export_project_file(project, path, z, include_images, keep_compute_id, allow_all_nodes, temporary_dir):
    

    # Image file that we need to include in the exported archive
    images = []

    with open(path) as f:
        topology = json.load(f)

    if "topology" in topology:
        if "nodes" in topology["topology"]:
            for node in topology["topology"]["nodes"]:
                compute_id = node.get('compute_id', 'local')

                if node["node_type"] == "virtualbox" and node.get("properties", {}).get("linked_clone"):
                    raise aiohttp.web.HTTPConflict(text="Topology with a linked {} clone could not be exported. Use qemu instead.".format(node["node_type"]))
                if not allow_all_nodes and node["node_type"] in ["virtualbox", "vmware", "cloud"]:
                    raise aiohttp.web.HTTPConflict(text="Topology with a {} could not be exported".format(node["node_type"]))

                if not keep_compute_id:
                    node["compute_id"] = "local"  # To make project portable all node by default run on local

                if "properties" in node and node["node_type"] != "docker":
                    for prop, value in node["properties"].items():

                        if node["node_type"] == "iou":
                            if not prop == "path":
                                continue
                        elif not prop.endswith("image"):
                            continue
                        if value is None or value.strip() == '':
                            continue

                        if not keep_compute_id:  # If we keep the original compute we can keep the image path
                            node["properties"][prop] = os.path.basename(value)

                        if include_images is True:
                            images.append({
                                'compute_id': compute_id,
                                'image': value,
                                'image_type': node['node_type']
                            })

        if not keep_compute_id:
            topology["topology"]["computes"] = []  # Strip compute information because could contain secret info like password

    local_images = set([i['image'] for i in images if i['compute_id'] == 'local'])

    for image in local_images:
        _export_local_images(project, image, z)

    remote_images = set([
        (i['compute_id'], i['image_type'], i['image'])
        for i in images if i['compute_id'] != 'local'])

    for compute_id, image_type, image in remote_images:
        yield from _export_remote_images(project, compute_id, image_type, image, z, temporary_dir)

    z.writestr("project.gns3", json.dumps(topology).encode())

    return images
779887
function copyResources() {
  // Source code deps
  fileUtil.copyFile(path.resolve(docsDir, '../dist/leonardo-ui.js'), path.resolve(docsDir, 'dist/leonardo-ui/leonardo-ui.js'));
  fileUtil.copyFile(path.resolve(docsDir, '../dist/leonardo-ui.js.map'), path.resolve(docsDir, 'dist/leonardo-ui/leonardo-ui.js.map'));
  fileUtil.copyFile(path.resolve(docsDir, '../dist/leonardo-ui.css'), path.resolve(docsDir, 'dist/leonardo-ui/leonardo-ui.css'));
  fileUtil.copyFile(path.resolve(docsDir, '../dist/leonardo-ui.css.map'), path.resolve(docsDir, 'dist/leonardo-ui/leonardo-ui.css.map'));
  fileUtil.copyFile(path.resolve(docsDir, '../dist/lui-icons.ttf'), path.resolve(docsDir, 'dist/leonardo-ui/lui-icons.ttf'));
  fileUtil.copyFile(path.resolve(docsDir, '../dist/lui-icons.woff'), path.resolve(docsDir, 'dist/leonardo-ui/lui-icons.woff'));

  // Doc files
  glob.sync(`${path.resolve(docsDir, 'src/img')}/**.*`).forEach((file) => {
    const folder = path.resolve(docsDir, 'src/img/').replace(/\\/g, '/'); // Because glob uses forward slashes on all paths
    const fileName = file.replace(folder, '');
    fileUtil.copyFile(file, path.resolve(docsDir, `dist/resources/${fileName}`));
  });
}
359441
def collect_static_files(src_map, dst):
    
    for rel_src, abs_src in src_map.iteritems():
        abs_dst = os.path.join(dst, rel_src)
        copy_file(abs_src, abs_dst)
317913
function copyFiles() {
  return mergeStream(
    // CSS source
    gulp.src([
      'css-components/**/*',
      '!css-components/onsen-visual-design-spec.sketch',
      '!css-components/build/',
      '!css-components/build/**/*',
      '!css-components/node_modules/',
      '!css-components/node_modules/**/*',
      '!css-components/npm-debug.log'
    ])
      .pipe(gulp.dest('build/css-components-src/')),

    // These are not used (already loaded by gulp-replace)
    // gulp.src('core/images/**/*')
    //   .pipe(gulp.dest('build/images/')),

    // package.json (for the bindings which uses `build` directory)
    gulp.src([
      'package.json',
    ])
      .pipe(gulp.dest('build/')),

    // type definitions copy
    gulp.src('core/src/onsenui.d.ts')
      .pipe(gulp.dest('build/js/')),
  );
}
737286
def copy_dependency_images(tile):
    """"""

    env = Environment(tools=[])

    outputbase = os.path.join('build', 'output')
    depbase = os.path.join('build', 'deps')
    for dep in tile.dependencies:
        depdir = os.path.join(depbase, dep['unique_id'])
        outputdir = os.path.join(outputbase)

        deptile = IOTile(depdir)

        for image in deptile.find_products('firmware_image'):
            name = os.path.basename(image)
            input_path = os.path.join(depdir, name)
            output_path = os.path.join(outputdir, name)
            env.Command([output_path], [input_path], Copy("$TARGET", "$SOURCE"))
1299725
def save_docs(self, files=None, output_dir=None):
        
        if output_dir:
            try:
                os.mkdir(output_dir)
            except OSError:
                pass

            try:
                import pkg_resources
                save_file(os.path.join(output_dir, 'jsdoc.css'),
                    pkg_resources.resource_string(__name__, 'static/jsdoc.css'))
            except (ImportError, IOError):
                try:
                    import shutil
                    base_dir = os.path.dirname(os.path.realpath(__file__))
                    css_file = os.path.join(base_dir, 'jsdoc.css')
                    shutil.copy(css_file, output_dir)
                except IOError:
                    print('jsdoc.css not found.  HTML will not be styled.')

            save_file('%s/index.html' % output_dir, 
                    build_html_page('Module index', self.to_html()))
        else:
            output_dir = '.'

        if files is None:
            files = list(self.keys())

        for filename in files:
            try:
                doc = self[filename]
                save_file('%s/%s.html' % (output_dir, trim_js_ext(doc.name)), 
                        build_html_page(doc.name, doc.to_html(self)))
            except KeyError:
                warn('File %s does not exist', filename)
1025746
function(plugin_dir, src, project_dir, dest, link) {
        var target_path = common.resolveTargetPath(project_dir, dest);
        if (fs.existsSync(target_path))
            throw new Error('"' + target_path + '" already exists!');

        common.copyFile(plugin_dir, src, project_dir, dest, !!link);
    }
96745
def build(self, input_path, output_paths):
        """"""
        for output in output_paths:
            shutil.copy(input_path, output_paths)
717077
function addFavicons() {
  var stream = new Transform({objectMode: true, highWaterMark: 2});

  var hosts = {};
  var downloads = [];
  stream._transform = function (page, _, callback) {
    stream.push(page);
    var host = url.parse(page.url).host;
    if (!hosts[host]) {
      downloads.push(hosts[host] = download(url.resolve(page.url, '/favicon.ico')).then(function (result) {
        if (result.statusCode === 200 &&
            !(result.headers['content-type'] &&
              result.headers['content-type'].indexOf('html') !== -1)) {
          stream.push(result);
        }
      }, function () {
        //ignore errors downloading favicons
      }));
    }
    callback(null);
  };
  stream._flush = function (callback) {
    Promise.all(downloads).done(function () {
      callback();
    }, function (err) {
      stream.emit('error', err);
      callback();
    });
  };
  
  return stream;
}
1070428
def makefile(dir = Dir.pwd, options = {})
      path = normalized_path(dir)
      path = FalkorLib::Git.rootdir(path) if FalkorLib::Git.init?(path)
      info "=> Setup a root repository makefile in '#{dir}'"
      # Preparing submodule
      submodules = {}
      submodules['Makefiles'] = {
        :url    => 'https://github.com/Falkor/Makefiles.git',
        :branch => 'devel'
      }
      FalkorLib::Git.submodule_init(path, submodules)
      makefile = File.join(path, "Makefile")
      if File.exist?( makefile )
        puts "  ... not overwriting the root Makefile which already exists"
      else
        src_makefile = File.join(path, FalkorLib.config.git[:submodulesdir],
                                 'Makefiles', 'repo', 'Makefile')
        FileUtils.cp src_makefile, makefile
        gitflow_branches = FalkorLib::Config::GitFlow::DEFAULTS[:branches]
        if FalkorLib::GitFlow.init?(path)
          [ :master, :develop ].each do |b|
            gitflow_branches[b.to_sym] = FalkorLib::GitFlow.branches(b.to_sym)
          end
        end
        unless options.nil?
          [ :master, :develop ].each do |b|
            gitflow_branches[b.to_sym] = options[b.to_sym] if options[b.to_sym]
          end
        end
        info "adapting Makefile to the gitflow branches"
        Dir.chdir( path ) do
          run %(
   sed -i '' \
        -e \"s/^GITFLOW_BR_MASTER=production/GITFLOW_BR_MASTER=#{gitflow_branches[:master]}/\" \
        -e \"s/^GITFLOW_BR_DEVELOP=devel/GITFLOW_BR_DEVELOP=#{gitflow_branches[:develop]}/\" \
        Makefile
                        )
        end
        FalkorLib::Git.add(makefile, 'Initialize root Makefile for the repo')
      end
    end
94627
function createIconFiles(srcFile, dest) {
  const thisTaskName = swlog.logSubStart('create icon files');

  return new Promise(resolve => {
    const exportArtboardsOptions = [
      'export',
      'artboards',
      srcFile,
      `--formats=${options.iconFormats.join(',')}`,
      '--include-symbols=NO',
      '--save-for-web=YES',
      `--output=${dest}`
    ];

    const outputStr = sketchtoolExec(exportArtboardsOptions.join(' '));
    resolve(outputStr);
  })
  .then(output => {
    options.iconFormats.forEach(format => {
      const regex = new RegExp(`\\.${format}`, 'g');
      const count = (output.match(regex) || []).length;
      swlog.logTaskAction('Created', `${count} ${format.toUpperCase()} files`);
    })

    swlog.logSubEnd(thisTaskName);

    if (options.iconFormats.indexOf('svg') !== -1) {
      return optimizeSVGs(dest);
    }
  });
}
584717
def BuildWithPyInstaller(self):
    """"""
    self.CleanDirectory(
        config.CONFIG.Get("PyInstaller.distpath", context=self.context))

    logging.info("Copying pyinstaller support files")
    self.spec_file = os.path.join(self.build_dir, "grr.spec")

    with open(self.spec_file, "wb") as fd:
      fd.write(config.CONFIG.Get("PyInstaller.spec", context=self.context))

    with open(os.path.join(self.build_dir, "version.txt"), "wb") as fd:
      fd.write(config.CONFIG.Get("PyInstaller.version", context=self.context))

    shutil.copy(
        src=config.CONFIG.Get("PyInstaller.icon_path", context=self.context),
        dst=os.path.join(self.build_dir, u"grr.ico"))

    # We expect the onedir output at this location.
    self.output_dir = os.path.join(
        config.CONFIG.Get("PyInstaller.distpath", context=self.context),
        "grr-client")

    # Pyinstaller doesn't handle unicode strings.
    args = [
        "--distpath",
        str(config.CONFIG.Get("PyInstaller.distpath", context=self.context)),
        "--workpath",
        str(
            config.CONFIG.Get("PyInstaller.workpath_dir",
                              context=self.context)),
        str(self.spec_file)
    ]
    logging.info("Running pyinstaller: %s", args)
    PyInstallerMain.run(pyi_args=[utils.SmartStr(x) for x in args])

    # Clear out some crud that pyinstaller includes.
    for path in ["tcl", "tk", "pytz"]:
      dir_path = os.path.join(self.output_dir, path)
      try:
        shutil.rmtree(dir_path)
      except OSError:
        logging.error("Unable to remove directory: %s", dir_path)

      try:
        os.mkdir(dir_path)
      except OSError:
        logging.error("Unable to create directory: %s", dir_path)

      file_path = os.path.join(dir_path, path)
      try:
        # Create an empty file so the directories get put in the installers.
        with open(file_path, "wb"):
          pass
      except IOError:
        logging.error("Unable to create file: %s", file_path)

    version_ini = version.VersionPath()
    shutil.copy(version_ini, os.path.join(self.output_dir, "version.ini"))

    with open(os.path.join(self.output_dir, "build.yaml"), "wb") as fd:
      self.WriteBuildYaml(fd)
1326995
def copy_assets(self, output_path):
        
        src_paths = []

        # if we have a theme
        if self.config.theme is not None:
            # assume it's in the folder: "themes/theme_name/assets"
            src_paths.append(os.path.join(
                self.path,
                StatikProject.THEMES_DIR,
                self.config.theme,
                StatikProject.ASSETS_DIR
            ))
            # NOTE: Adding the theme's assets directory *before* the project's internal assets
            #       directory always ensures that the project's own assets are copied *after* the
            #       theme's, thereby ensuring that the project's assets folder takes precedence
            #       over the theme's.

        # always attempt to copy from our base assets folder
        if os.path.isabs(self.config.assets_src_path):
            src_paths.append(self.config.assets_src_path)
        else:
            src_paths.append(os.path.join(self.path, self.config.assets_src_path))

        for src_path in src_paths:
            if os.path.exists(src_path) and os.path.isdir(src_path):
                dest_path = self.config.assets_dest_path
                if not os.path.isabs(dest_path):
                    dest_path = os.path.join(output_path, dest_path)

                asset_count = copy_tree(src_path, dest_path)
                logger.info("Copied %s asset(s) from %s to %s", asset_count, src_path, dest_path)
            else:
                logger.info(
                    "Missing assets source path - skipping copying of assets: %s",
                    src_path
                )
164258
function generateUtilityFiles(next) {
    fs.copy(path.join(getConfig('template.folder'), 'index.js'), path.join(getConfig('output.folder'), 'index.js'), function (err) {
        if (err) { next(err); return; }
        if (getConfig('output.log')) { logger.info('(Created) Index file: ' + path.resolve(path.join(getConfig('output.folder'), 'index.js'))); }
        fs.copy(path.join(getConfig('template.folder'), '..', 'utils.js'), path.join(getConfig('output.folder'), 'utils.js'), function (err) {
            if (err) { next(err); return; }
            next(null);
        });
    });
    try {
        overriddenAliases = require(path.join(process.cwd(), getConfig('output.folder'), 'alias.json'));
    } catch (ignore) {}
}
841746
function(dir, kits, file) {
                        var fillindex = kits.indexOf(file);
                        if (fillindex != -1) {
                            var copySnippet = path.join(dir, file);
                            var copySrc = copySnippet.replace(snipConfig, srcFile);
                            var data = fs.readFileSync(copySnippet, 'utf-8');
                            fse.ensureFileSync(copySrc);
                            fs.writeFileSync(copySrc, data, 'utf-8');
                            // console.log("copySnippet:",copySnippet,"...copySrc",copySrc)
                        }
                    }