How to use the node-elm-compiler.compileSync function in node-elm-compiler

To help you get started, we’ve selected a few node-elm-compiler examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NoRedInk / json-elm-schema / cli / index.js View on Github external
var temp = require('temp').track()
var compiler = require('node-elm-compiler')
var meow = require('meow')

var cli = meow(`
    Usage
      $ elm-json-schema 
`)

if (!fs.existsSync('./elm-package.json')) {
  fail('Error: This command needs to be executed from the root of the elm project.')
}

var sourcePath = cli.input[0]
var targetPath = temp.path({ suffix: '.js' })
compiler.compileSync([sourcePath], {
  yes: true,
  output: targetPath,
  processOpts: { stdio: 'pipe' }
})
var Elm = require(targetPath)
var app = Elm.Main.worker()
app.ports.emit.subscribe(function (json) {
  console.log(json)
})

function fail (msg) {
  process.stderr.write(msg)
  process.exit(1)
}

node-elm-compiler

A Node.js interface to the Elm compiler binaries.

BSD-3-Clause
Latest version published 4 years ago

Package Health Score

51 / 100
Full package analysis