dcodeIO / MetaScript

Sophisticated meta programming in JavaScript, e.g. to build different versions of a library from a single source tree.
http://dcode.io
Apache License 2.0
137 stars 13 forks source link

Import another JS file #3

Closed loncar closed 9 years ago

loncar commented 9 years ago

Hi, I have been trying to import file like in your example :

//main.js file
/*? includeFile = function(file) {
     write(indent(require("fs").readFileSync(file)), __);
} */

//? includeFile("models/location.js")

After runnig metascript I get this exception : ...has no method 'split' in meta program of 'main.js':

metascript main.js > main.prod.js

There has been some issues with installation of metascript, after npm command metascript didn't work. I have to run apt-get install nodejs-legacy to make it work. I don't know if those two things are connected.

Thanks

dcodeIO commented 9 years ago

There is already some inbuilt utility, maybe the example is a bit misleading (it's really just an example). See: https://github.com/dcodeIO/MetaScript#built-in-utility

Have you tried include(...) instead?

loncar commented 9 years ago

Thanks for quick answer, i didn't use include . I was too tired for reading and it didn't catch my eye. It's working now with include :+1: Thanks again and sorry for the false alarm.