정말 격렬합니다. 어디에서나 불법적 인 일을하는 곳에서는 코드를 찾을 수 없지만 어떤 이유로 든 을 호출하면 프로그램이 망가질 수 있습니다. 여기에 코드가 있습니다. 관련 부분은 svgToPNG에 있으며 여기서 나는 fork
이라고 부릅니다. 내가 밖으로 fork
라인을하고, 그 위치에 다른 내용을 교체 할 경우Coffeescript 예기치 않은 토큰 ILLEGAL, 불법적이면 안됩니다.
{fork} = require 'child_process'
{Coral} = require 'coral'
svgToPNG = (svg, reply, log) ->
log "converting SVG to a PNG"
# set up a child process to call convert svg: png:-
convert = fork '/usr/bin/env', ['convert', 'svg:', 'png:-']
log "Spawned child process running convert, pid " + convert.pid
# set up behavior when an error occurs
convert.stderr.on "data", ->
log "Error occurred while executing convert"
reply "error"
# set up behavior for when we successfully convert
convert.stdout.on "data", ->
log "Successful conversion! :)"
log "here's the data: " + data
reply data
# pipe the SVG into the stdin of the process (starting it)
convert.stdin.end svg
은, 모든 도리 늠름한,하지만 난 그것을에서 떠나면, 내가 얻을 :
> coffee src/coral_client.coffee
finished doing conversion to svg!
converting SVG to a PNG
Spawned child process running convert, pid 60823
/usr/bin/grep:1
(function (exports, require, module, __filename, __dirname) { ����
^
SyntaxError: Unexpected token ILLEGAL
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:901:3
그것은 아무 의미가 없습니다. 난 this question 같은 이상한 불법 유니 코드 문자가 없어, 내가 어떤 종류의 구문 분석 오류가 있다고 생각하지 않아 this one ... 정말 무슨 일이 일어나고 있는지 모르겠다.
CoffeeScript가 어떻게 든 코드를 위반할 수 있습니까? 그럴 것 같지 않지만 모르겠다.
어떤 파일을 변환하고 있습니까? 그것은'svg : somefilename png : -'로 변환하면 안됩니까? – hpaulj
이 스크립트를 컴파일 한 다음'node'를 사용하여'js'를 실행하려고 시도 했습니까? 'js'가 잘 보이는 경우 문제는 coffeescript가 아닙니다. – hpaulj
@hpaulj svg 파일이 프로세스의 표준 입력으로 파이프됩니다. –