Copy transpiled file to clipboard on save - help writing custom function


#1

Hi everyone - I’m trying to write a small customization to work along with the language-babel package. I want to be transpile to clipboard basically.

babel = require('babel-core')

atom.commands.add 'atom-text-editor',
  'language-babel:copy-to-clipboard': (event) ->
    editor = atom.workspace.getActiveTextEditor()
    editorText = editor.getText()
    transpiledText = babel.transform(editorText).code
    atom.clipboard.write transpiledText

However, I can’t require babel-core in the init.coffee file – it works in the console … what’s the best way to set about accomplishing this? Thanks!