src/cli.js
function compileFile(srcPath, dstPath, format, toStdout) {
    if (! fs.existsSync(dstPath)) {
        makePath(dstPath)
    }

    fs.readFile(srcPath, 'utf8', function(err, data) {
        if (err) throw err

        var cwd         = process.cwd()
        var smapDstPath = dstPath + '.map'
        var smapSrcPath = path.relative(
            path.dirname(
                path.join(cwd, dstPath)),
                path.join(cwd, srcPath))
        var result = ram.compile(data, {
            filename : srcPath,
            format  : format,
            sourceMap: !toStdout,
            sourceMapCfg: {
                source: smapSrcPath,
                sourceContent: data
            }
        })

        if (toStdout) {
            process.stdout.write(result.js + '\n')
            return
        }

        if (result.js) {
            result.js = result.js + '\n//# sourceMappingURL=' + path.basename(dstPath) + '.map'
            fs.writeFile(dstPath, result.js, 'utf8', function(err) {
                if (err) throw err
            })
        }

        if (result.sourceMap) {
            fs.writeFile(smapDstPath, result.sourceMap, 'utf8', function(err) {
                if (err) throw err
            })
        }
    })
}
function compileFile(srcPath, dstPath, format, toStdout) {
    if (! fs.existsSync(dstPath)) {
        makePath(dstPath)
    }

    fs.readFile(srcPath, 'utf8', function(err, data) {
        if (err) throw err

        var cwd         = process.cwd()
        var smapDstPath = dstPath + '.map'
        var smapSrcPath = path.relative(
            path.dirname(
                path.join(cwd, dstPath)),
                path.join(cwd, srcPath))
        var result = ram.compile(data, {
            filename : srcPath,
            format  : format,
            sourceMap: !toStdout,
            sourceMapCfg: {
                source: smapSrcPath,
                sourceContent: data
            }
        })

        if (toStdout) {
            process.stdout.write(result.js + '\n')
            return
        }

        if (result.js) {
            result.js = result.js + '\n//# sourceMappingURL=' + path.basename(dstPath) + '.map'
            fs.writeFile(dstPath, result.js, 'utf8', function(err) {
                if (err) throw err
            })
        }

        if (result.sourceMap) {
            fs.writeFile(smapDstPath, result.sourceMap, 'utf8', function(err) {
                if (err) throw err
            })
        }
    })
}
compile a the provided file containig RamdaScript code and save the resulting JavaScript code, if the destiny path is omitted the JavaScript code will be saved adjacent to the RamdaScript source file