Folkwise-io / mintbean-cli

MIT License
13 stars 9 forks source link

Copy images #12

Closed clairefro closed 4 years ago

clairefro commented 4 years ago

previously ejs.compile() was corrupting binary files, like images, which wouldn't copy properly to project folder. Added hacky gaurd clause to only ejs.compile() on files with content that matches the template <%=.*=>

const templateBuffer = fs.readFileSync(absolutePath)
      const templateString = templateBuffer.toString()

      // if templatable, compile with ejs
      let output = (/<%=.*%>/.test(templateString)) ?
                   ejs.compile(templateString)(options) :
                   templateBuffer;
      const tmpDestination = path.join(temporaryDirectory, pathFromDirectoryRoot);
      ensureDirectoryExistence(tmpDestination);
      fs.writeFileSync(tmpDestination, output);

Also disabled templating unit tests because unsure of how to handle new flow with user input (inquirer)