4 Commits

Author SHA1 Message Date
af10b4eee5 2.0.4 2019-09-04 15:45:18 +02:00
fdc9cb6784 fix(core): update 2019-09-04 15:45:18 +02:00
8db0cac292 2.0.3 2019-09-04 14:19:43 +02:00
dad6119945 fix(core): update 2019-09-04 14:19:43 +02:00
7 changed files with 76 additions and 3 deletions

13
.snyk Normal file
View File

@ -0,0 +1,13 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.13.5
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
ignore:
SNYK-JS-JSYAML-173999:
- gray-matter > js-yaml:
reason: None given
expires: '2019-10-04T12:19:33.385Z'
SNYK-JS-JSYAML-174129:
- gray-matter > js-yaml:
reason: None given
expires: '2019-10-04T12:19:33.385Z'
patch: {}

29
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,29 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "current file",
"type": "node",
"request": "launch",
"args": [
"${relativeFile}"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": "test.ts",
"type": "node",
"request": "launch",
"args": [
"test/test.ts"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
}
]
}

View File

@ -1,6 +1,8 @@
# @pushrocks/smartfm
frontmatter done right
> Please consider following us on https://beta.news/lossless to subscribe to infos on changes and updates.
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartfm)
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartfm)

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartfm",
"version": "2.0.2",
"version": "2.0.4",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartfm",
"version": "2.0.2",
"version": "2.0.4",
"private": false,
"description": "frontmatter done right",
"main": "dist/index.js",

View File

@ -23,7 +23,23 @@ tap.test('should stringify data', async () => {
});
tap.test('should parse a normal frontmatter file', async () => {
const normalFile = `---
heythere: awesome
---
really
`;
let result = testSmartfm.parse(normalFile);
expect(result.data.heythere).to.equal('awesome')
});
tap.test('should parse a commented out frontmatter file', async () => {
const commentedFile = `# ---
# heythere: awesome
# ---
really
`;
let result = testSmartfm.parseFromComments('# ', commentedFile);
console.log(result);
});
tap.start();

View File

@ -29,4 +29,17 @@ export class Smartfm {
parse(stringToParse: string) {
return grayMatter(stringToParse);
}
/**
* parse from commnets
*/
parseFromComments(commentStart: string, stringToParse: string) {
const diffFunc = (diffMe, diffBy) => diffMe.split(diffBy).join('');
let lines = stringToParse.split('\n');
lines = lines.map(line => {
return diffFunc(line, commentStart);
});
const cleanedString = lines.join('\n');
return this.parse(cleanedString);
}
}