generated from spatie/package-skeleton-php
-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Merge pull request #26 from spatie/feature/generate-using-cli"
- Loading branch information
Showing
5 changed files
with
73 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import mjml2html from 'mjml' | ||
|
||
const args = JSON.parse(atob(process.argv.slice(2))); | ||
|
||
const mjml = args[0]; | ||
const options = args[1]; | ||
|
||
let result = '' | ||
|
||
try { | ||
result = await mjml2html(mjml, options); | ||
} catch (exception) { | ||
const errorString = JSON.stringify({mjmlError: exception.toString()}); | ||
|
||
process.stdout.write(utoa(errorString)); | ||
process.exit(0); | ||
} | ||
|
||
process.stdout.write(utoa(JSON.stringify(result))); | ||
|
||
/** | ||
* Unicode to ASCII (encode data to Base64) | ||
* @param {string} data | ||
* @return {string} | ||
*/ | ||
function utoa(data) { | ||
return btoa(unescape(encodeURIComponent(data))); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters