Skip to content

Commit

Permalink
export file info
Browse files Browse the repository at this point in the history
  • Loading branch information
kbrsh committed Jul 18, 2018
1 parent 6e73fbb commit e293cf1
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/moon-mvl/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ const addClass = (element, name) => {
};

module.exports = (file, contents) => {
const fileName = path.basename(file).slice(0, -4);
const directoryName = path.dirname(file);
const name = path.basename(directoryName);

let js = "import Moon from \"moon\";";
let css;

let view = "";
let data = "{};";

const fileName = path.basename(file).slice(0, -4);
const directoryName = path.dirname(file);
const name = path.basename(directoryName);

if (fs.existsSync(path.join(directoryName, fileName + ".js"))) {
js += `import data from ".${path.sep}${fileName}.js";`;
data = "data;";
Expand All @@ -73,6 +73,8 @@ module.exports = (file, contents) => {
js += `export default Moon.extend("${name}",function(){var options=${data}options.view=function(m,instance,locals){${view}};return options;});`;

return {
name: name,
fileName: fileName,
js: js,
css: css
};
Expand Down

0 comments on commit e293cf1

Please sign in to comment.