Skip to content

Commit

Permalink
Drop EJS for README generation
Browse files Browse the repository at this point in the history
  • Loading branch information
kemitchell committed Sep 21, 2023
1 parent 4aa7f81 commit 342bdad
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 25 deletions.
23 changes: 0 additions & 23 deletions README.ejs

This file was deleted.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
},
"devDependencies": {
"defence-cli": "^2.0.1",
"ejs": "^3.1.9",
"replace-require-self": "^1.1.1",
"standard": "^11.0.0"
},
Expand All @@ -35,7 +34,7 @@
"index.js"
],
"scripts": {
"build": "ejs -f examples.json README.ejs > README.md",
"build": "node write-readme.js > README.md",
"pretest": "npm run build",
"prepublish": "npm run build",
"test": "npm run test:suite && npm run test:readme",
Expand Down
31 changes: 31 additions & 0 deletions write-readme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
var examples = require('./examples.json')
function write (string) { process.stdout.write(string + '\n') }

write('`satisfies(SPDX license expression, array of approved licenses)`')
write('')

write('Approved licenses may be simple license identifiers like `MIT`, plus-ranges like `EPL-2.0+`, or licenses with exceptions like `Apache-2.0 WITH LLVM`. They may _not_ be compound expressions using `AND` or `OR`.')
write('')

write('```javascript')
write("var assert = require('assert')")
write("var satisfies = require('spdx-satisfies')")
write('')

write('// True Examples')
write('for (const [spdxExpression, arrayOfApproved] of [')
write(examples.returnTrue.map(function (e) { return ' ' + JSON.stringify(e) }).join(',\n'))
write(']) assert(satisfies(spdxExpression, arrayOfApproved))')
write('')

write('// False Examples')
write('for (const [spdxExpression, arrayOfApproved] of [')
write(examples.returnFalse.map(function (e) { return ' ' + JSON.stringify(e) }).join(',\n'))
write(']) assert(!satisfies(spdxExpression, arrayOfApproved))')
write('')

write('// Exceptions')
write('for (const [spdxExpression, arrayOfApproved] of [')
write(examples.throwErrors.map(function (e) { return ' ' + JSON.stringify(e) }).join(',\n'))
write(']) assert.throws(function () { satisfies(spdxExpression, arrayOfApproved) })')
write('```')

0 comments on commit 342bdad

Please sign in to comment.