想要帮助将命令输出作为CoffeeScript中的变量吗

想要帮助将命令输出作为CoffeeScript中的变量吗,coffeescript,Coffeescript,所以我想用Ubersicht为我的Macbook做一个电池部件,虽然我有这个,但我希望它可以在不同的电池百分比下有不同的颜色。现在,代码如下所示: command: "pmset -g batt | grep -o '[0-9]*%'" refreshFrequency: 60000 style: """ bottom: 632px left: 10px color: #fff font-family: Helvetica Neue div display: b

所以我想用Ubersicht为我的Macbook做一个电池部件,虽然我有这个,但我希望它可以在不同的电池百分比下有不同的颜色。现在,代码如下所示:

command: "pmset -g batt | grep -o '[0-9]*%'"

refreshFrequency: 60000

style: """
  bottom: 632px
  left: 10px
  color: #fff
  font-family: Helvetica Neue

  div
    display: block
    text-shadow: 0 0 1px rgba(#000, 0.5)
    font-size: 60px
    font-weight: 100
    background: rgba(#070, .3)
    position: absolute
    margin-bottom: 5px
    border-radius: 10px
    padding 3px 5px 3px


"""


render: -> """
  <div class='battery'></div>
"""

update: (output, domEl) ->
  $(domEl).find('.battery').html(output)

你能帮我做这个吗?如果你们能帮我解决这个问题,我将不胜感激,因为我已经找了整整两天的解决方案。

这里没有足够的信息。你能显示完整文件和完整错误吗?这是完整文件和完整错误。如果时间长一点,我还是会把整件事都贴在这里。
batteryPercent=command:“pmset-g batt | grep-o'[0-9]*%'”
使
batteryPercent
成为散列。然后你说
batteryPercent>=60%
,这是错误的,原因有很多
60%
不是一个有效的术语,即使它是一个数字,也不应该与哈希进行比较
batteryPercent.command
可以被解释为使用
execSync
或其他方法的shell命令。无论如何,我不认为您显示的代码会引起您显示的错误,所以我打赌这不是代码的最新版本。也许你可以用你最近的代码修改这个问题。
command: "pmset -g batt | grep -o '[0-9]*%'"
batteryPercent = command: "pmset -g batt | grep -o '[0-9]*%'"

refreshFrequency: 60000

batteryColor = '#070' if batteryPercent >= 60%
batteryColor = '#770' batteryPercent < 60%
batteryColor = '#700' if batteryPercent <= 30%

...

background: rgba(#{batteryColor}, .3)
ReferenceError: Can't find variable: batteryPercent