Handle file upgrades.

@param {Mixed} err
@param {String} content
@api private
558159
function done(err, content) {
            if (err) return cb(err);

            var code = JSON.parse(self.square.package.source)
              , current = bundle.version || self.version(bundle.meta.content)
              , source;

            code.bundle[key].version = version;
            bundle.version = version;
            bundle.content = content;

            // now that we have updated the shizzle, we can write a new file
            // also update the old source with the new version
            source = JSON.stringify(code, null, 2);
            self.square.package.source = source;

            try {
              async.parallel([
                  async.apply(fs.writeFile, self.square.package.location, source)
                , async.apply(fs.writeFile, bundle.meta.location, content)
              ], function (err, results) {
                self.square.logger.notice(
                    'sucessfully updated %s from version %s to %s'
                  , key
                  , current.grey
                  , version.green
                );

                cb(err);
              });
            } catch (e) { err = e; }
          }
701046
function (err) {
            try {
                safeDeleteTempFile();
                doneFn(me.reorderFiles(
                    files
                ));
            } catch (e) {
                grunt.log.error(e);
                safeDeleteTempFile();
            }
        }
146258
protected function _loadFileErrorHandler($errno, $errstr, $errfile, $errline)
    {
        if ($this->_loadFileErrorStr === null) {
            $this->_loadFileErrorStr = $errstr;
        } else {
            $this->_loadFileErrorStr .= (PHP_EOL . $errstr);
        }
    }
257544
function errHandler(err) {
    /* istanbul ignore else */
    if (_output) {
      err = err instanceof Error ? err : new Error(err)
      _emitter.emit('end', err)
      _output = null
    }
    else
      console.error('jspreproc: ' + err)
  }
311114
function(src, dest){
      self.logger.warn('File at '+dest+' exists, overwrite?');
      
      rl.question('(yN) ', function(answer){
        switch(answer.toLowerCase()){
          case 'y':
            this.copy(src, dest); 
            this.triggerNext(); 
            break; 
          case 'n':
            this.triggerNext(); 
            break; 
          default:
            this.waitForResponse(src, dest); 
            break; 
        }
      }.bind(this)); 
    }
333887
function _process( content ) {
    var reg = /((?:\/\/.*?\n)|(?:\/\*[\s\S]*?\*\/))|(?:@import\s([\s\S]*?)(?:\n|$)(?!\s+[^{@]*\n))/ig;
    // var reg = /@import[\s\S]*?;/ig;
    var rUrl = /^url/i;
    var rEnd = /;$/;

    content = fixLineBreak( content );

    return content.replace( reg, function( all, comments, value ) {
        var files;

        value = value ? value.trim().replace( rEnd, '' ) : '';

        // If it's comments or If the @import has any media queries.
        if ( comments || /('|").*?\1\s+[^'"]+$/.exec(value) ) {
            return all;
        }

        files = value.split(/\s*,?\s+/m).map(function( value ) {
            var quote = '',
                match;

            value = value.trim();
            match = /^('|")(.*)\1$/.exec( value );

            if ( match ) {
                value = match[ 2 ];
                quote = match[ 1 ];
            }

            // If the file’s extension is .css.
            if ( /\.css$/i.exec( value ) ||

                // If the filename begins with http://.
                /^http/i.exec( value ) ||

                // If the filename is a url().
                /^url/i.exec( value ) ) {
                return '@import ' + quote + value + quote + ';';
            }

            return map.wrap( value );
        });

        return files.join('\n');
    });
}
894791
function update () {
      sourceOrOptions.bundle()
        .pipe(concat(function (data) {
          add(filepath, data.toString())
        }))
        .on('error', function (err) {
          console.error(err.stack)
          ASSET_PENDING--
        })
    }
778997
function (evt, args) {
            var res = {
                content : null
            };
            if (evt.downloadFailed) {
                res.downloadFailed = evt.downloadFailed;
            }
            if (evt.logicalPaths.length > 0) {
                res.content = this.getFileContent(evt.logicalPaths[0]);
            }
            this.$callback(args.origCb, res);
        }
604096
function(err, res) {
	      console.log(err);
	      res.reply(mInstance.conf.CONST.ERR);
	      return;
	    }
922597
function ErroneousError(e, additional) {
    additional = additional || {};
    this.line = e.lineno || e.lineNumber || additional.lineno;
    this.file = e.filename || e.fileName || additional.filename;
    this.msg = e.message || additional.message;
    this.time = e.timestamp || additional.timestamp || Date.now();
    this.type = (this.parseMessage(this.msg) || e.type || e.name).toLowerCase();

    // If it's a DOM node, let's figure out which
    if (e.target) {
      this.target = this.getTargetIdentifier(e.target);

      if (e.target.nodeName) {
        this.type = 'resource';
        if (e.target.href) {
          this.file = e.target.href;
        } else if (e.target.src) {
          this.file = e.target.src;
        }
      }
    }

    // Parse the stack if any
    this.stack = e.stack;
    this.parseStack(e.stack);
  }
611669
function readDir(err, files) {
  if (err) {
    internalServerError.call(this, err);
  } else {
    var dirName = decodeURIComponent(
      getCurrentPathName(this)
    );
    this.output.push(
      "<!doctype html>",
      "<html>",
        "<head>",
          "<title>Index of ", dirName, "</title>",
          '<meta name="viewport" content="',
            'width=device-width,',
            'initial-scale=1.0,',
            'maximum-scale=1.0,',
            'user-scalable=no',
          '"/>',
          '<meta name="generator" content="polpetta" />',
        "</head>",
        "<body>",
          "<strong>Index of " + dirName + "</strong>",
          "<ul>"
    );
    if (dirName != WEB_SEP) {
      this.output.push(
        '<li><a href="..">..</a></li>'
      );
    }
    files.forEach(readDir.forEach, this.output);
    this.output.push(
          "</ul>",
        "</body>",
      "</html>"
    );
    this.output.flush(200, "text/html", "utf-8");
  }
}
1282581
function(file, content, callback) {
			fs.writeFile(file, content, 'ascii', function(err) {
				callback(err ? err : null);
			});
		}
1338333
function(peer, data, chunkIdx, fileObj, isLastChunk, updateProgress, emit){
  if (fileObj.fileWriter) { // todo, when the whole file is done writing, remove this fileWriter on fileObj(in tasks)
    doWriting(fileObj.fileWriter, fileObj, peer, chunkIdx, data, isLastChunk, updateProgress, emit);
  } else {
    fs(fileObj).then(fileExists).then(getFile).then(getFileWriter).then(function(writer) {
      doWriting(writer, fileObj, peer, chunkIdx, data, isLastChunk, updateProgress, emit);
    }, function(err) {
      emit('error/file', new FilerError({
        name: 'ChromeFileSystemError', code: "ERR_CHROME_FILESYSTEM_ERROR",  message: err.message || 'failed to get FileSystem Writer',
        peerID: peer._peerID, fileID: fileObj.fileID
      }));
      fileObj.fileWriter = null;
    });
  }
}
494097
function onOutError(err) {
    errNodecat = combineErrors(errNodecat, err);
    errStream.write(`nodecat: ${err}\n`);
    if (inCleanup) {
      inCleanup();
    }
    allDone();
  }
1301320
function(err) {
    notify.onError({
        title: "Error: " + err.plugin,
        subtitle: "<%= file.relative %>",
        message: "<%= error.message %>",
        sound: "Beep",
    })(err);
    console.log(err.toString())
    this.emit('end');
}
580100
function handleError(err) {
  if (typeof err === 'string' && errors[err]) {
    console.error(errors[err]);
  } else {
    if (argv.verbose) {
      console.error(err.stack);
    } else {
      console.error(err.message);
    }
  }
  process.exit(1);
}
1176015
function finish(err) {
      // Run callbacks when we have an error,
      // or when import parsing is complete.
      if (err || self.isParsed()) {
        // Cache the file after parsing:
        _.cacheFile(self);

        // Run all callbacks:
        for (var i=0; i < self._cb.length; i++) self._cb[i](err, self);
        self._cb = [];
      }
    }