0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

gruntでexpressを起動すると文字化けするのを解消

Posted at

個人的メモ

どうもgrunt.util.spawnが文字化けしてる。
grunt/lib/grunt/util.jsの最後の方を以下のように直したら化けなくなった。
自分のPCではテストもエラーになっていたが、grunt本家のテストではエラーになっていないようなので、原因が特定できない。この修正をすると自分のPCでもエラーはなくなる。

こちらの投稿が参考になった。
dataイベントで受け取るバッファの文字化け

  var child = spawn(cmd, args, opts.opts);
  var stdout = [];
  var stdoutLength = 0;
  var stderr = [];
  var stderrLength = 0;
  if (child.stdout) {
    child.stdout.on('data', function(buf) {
        stdout.push(buf);
        stdoutLength += buf.length;
    });
  }
  if (child.stderr) {
    child.stderr.on('data', function(buf) {
        stderr.push(buf);
        stderrLength += buf.length;
    });
  }
  child.on('close', function(code) {
    var so = Buffer.concat(stdout, stdoutLength);
    var se = Buffer.concat(stderr, stderrLength);
    callDone(code, so.toString(), se.toString());
  });
  return child;

0
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?