Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markdown to HTML in gulp script #639

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions Package/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,36 @@ const shelljs = require('shelljs');
const rename = require('gulp-rename');
const glob = require('glob');
const chalk = require('chalk');
const marked = require('marked');

let assemblediOSAndroidDir = 'Assembled-iOSAndroid';
let assembledWindowsDir = 'Assembled-Windows';
let basekitBuild = false;
let cmakeBasekitBuildDefinition = '';
let basekitPackagePath = '';


const makeHTMLNotice = async () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is marked async but then uses fs with callbacks. I believe these days you can do const fs = require('fs/promises') instead and use Promise returning async functions.

fs.readFile('../README.md', 'utf8', (err, data) => {
if (err) {
console.error('Error reading file:', err);
return;
}

// Convert Markdown to HTML
const html = marked.parse(data);

// Write the HTML to a file
fs.writeFile('../NOTICE.html', html, 'utf8', err => {
if (err) {
console.error('Error writing file:', err);
return;
}
console.log('NOTICE Conversion complete!');
});
});
};

function exec(command, workingDirectory = '.', logCommand = true) {
if (logCommand) {
log(command);
Expand Down Expand Up @@ -616,6 +639,8 @@ const build = gulp.series(buildIOSAndroid, switchToBaseKit, buildIOSAndroid);
const rebuild = gulp.series(clean, build);
const pack = gulp.series(rebuild, createPackage);

exports.buildNotice = makeHTMLNotice;

exports.validateAssembled = validateAssembled;
exports.validateAssemblediOSAndroid = validateAssemblediOSAndroid;

Expand Down
19 changes: 19 additions & 0 deletions Package/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Package/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@
"gulp": "^4.0.2",
"gulp-rename": "2.0.0",
"shelljs": "^0.8.4"
},
"dependencies": {
"marked": "^4.3.0"
}
}
Loading