Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@emdaer/core

Package Overview
Dependencies
Maintainers
4
Versions
135
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@emdaer/core - npm Package Compare versions

Comparing version 1.6.19 to 1.6.20

src/EmdaerFeatureFlags.test.js

8

CHANGELOG.md

@@ -6,2 +6,10 @@ # Change Log

<a name="1.6.20"></a>
## [1.6.20](https://github.com/emdaer/emdaer/compare/v1.6.19...v1.6.20) (2017-12-09)
**Note:** Version bump only for package @emdaer/core
<a name="1.6.19"></a>

@@ -8,0 +16,0 @@ ## [1.6.19](https://github.com/emdaer/emdaer/compare/v1.6.18...v1.6.19) (2017-11-27)

15

lib/EmdaerFeatureFlags.js

@@ -5,8 +5,15 @@ /* */

const EmdaerFeatureFlags = {
// Experimental AST parsing of Markdown files:
enableASTParsing: false,
// Experimental single comment type:
enableCommonComment: false,
// Experimental AST parsing of Markdown files and common comment type:
enableASTAndCommonComment: false,
};
Object.defineProperty(EmdaerFeatureFlags, 'override', {
enumerable: false,
writable: false,
configurable: false,
value(key, value) {
this[key] = value;
},
});
module.exports = EmdaerFeatureFlags;
/* */
const unified = require('unified');
const parseHtml = require('rehype-parse');
const parseMarkdown = require('remark-parse');
const convertMarkdownToHtml = require('remark-rehype');
const minifyHtml = require('rehype-preset-minify');
const outputHtml = require('rehype-stringify');
const EmdaerFeatureFlags = require('./EmdaerFeatureFlags');
const addStamp = require('./util/addStamp');

@@ -10,13 +19,28 @@ const executePlugins = require('./util/executePlugins');

const transforms = await identifyTransforms(content);
const contentWithPluginsExecuted = await executePlugins(content);
const contentWithTransformsApplied = await applyTransforms(
contentWithPluginsExecuted,
transforms
);
const text = stamp
? await addStamp(contentWithTransformsApplied, origin)
: contentWithTransformsApplied;
return text;
let output;
output = await executePlugins(content);
if (EmdaerFeatureFlags.enableASTAndCommonComment) {
output = await unified()
.use(parseHtml)
.use(parseMarkdown)
.use(convertMarkdownToHtml)
.use(minifyHtml)
.use(outputHtml)
.process(output)
.then(String)
.then(string => `${string}\n`);
}
output = await applyTransforms(output, transforms);
if (stamp) {
output = await addStamp(output, origin);
}
return output;
}
module.exports = emdaer;
{
"name": "@emdaer/core",
"description": "emdaer core",
"version": "1.6.19",
"version": "1.6.20",
"repository": "emdaer/emdaer",

@@ -16,3 +16,9 @@ "homepage": "https://emdaer.me/",

"dependencies": {
"js-yaml": "3.8.4"
"js-yaml": "3.8.4",
"rehype-parse": "4.0.0",
"rehype-preset-minify": "2.0.0",
"rehype-stringify": "3.0.0",
"remark-parse": "4.0.0",
"remark-rehype": "2.0.1",
"unified": "6.1.5"
},

@@ -19,0 +25,0 @@ "publishConfig": {

/* @flow */
type FeatureFlags = {|
enableASTParsing: boolean,
enableCommonComment: boolean,
export type FeatureFlags = {|
override?: (string, boolean) => void,
enableASTAndCommonComment: boolean,
|};
const EmdaerFeatureFlags: FeatureFlags = {
// Experimental AST parsing of Markdown files:
enableASTParsing: false,
// Experimental single comment type:
enableCommonComment: false,
// Experimental AST parsing of Markdown files and common comment type:
enableASTAndCommonComment: false,
};
Object.defineProperty(EmdaerFeatureFlags, 'override', {
enumerable: false,
writable: false,
configurable: false,
value(key, value) {
this[key] = value;
},
});
module.exports = EmdaerFeatureFlags;
/* @flow */
const unified = require('unified');
const parseHtml = require('rehype-parse');
const parseMarkdown = require('remark-parse');
const convertMarkdownToHtml = require('remark-rehype');
const minifyHtml = require('rehype-preset-minify');
const outputHtml = require('rehype-stringify');
const EmdaerFeatureFlags = require('./EmdaerFeatureFlags');
const addStamp = require('./util/addStamp');

@@ -10,13 +19,28 @@ const executePlugins = require('./util/executePlugins');

const transforms = await identifyTransforms(content);
const contentWithPluginsExecuted = await executePlugins(content);
const contentWithTransformsApplied = await applyTransforms(
contentWithPluginsExecuted,
transforms
);
const text = stamp
? await addStamp(contentWithTransformsApplied, origin)
: contentWithTransformsApplied;
return text;
let output;
output = await executePlugins(content);
if (EmdaerFeatureFlags.enableASTAndCommonComment) {
output = await unified()
.use(parseHtml)
.use(parseMarkdown)
.use(convertMarkdownToHtml)
.use(minifyHtml)
.use(outputHtml)
.process(output)
.then(String)
.then(string => `${string}\n`);
}
output = await applyTransforms(output, transforms);
if (stamp) {
output = await addStamp(output, origin);
}
return output;
}
module.exports = emdaer;

@@ -15,6 +15,10 @@ /* eslint-disable import/no-unresolved, import/no-extraneous-dependencies */

jest.mock('./EmdaerFeatureFlags');
const emdaer = require('./');
const EmdaerFeatureFlags = require('./EmdaerFeatureFlags');
describe('@emdaer/core', () => {
it('processes an .emdaer.md file', async () => {
EmdaerFeatureFlags.enableASTAndCommonComment = false;
expect(

@@ -47,2 +51,3 @@ await emdaer(

it('processes an .emdaer.md file without a stamp', async () => {
EmdaerFeatureFlags.enableASTAndCommonComment = false;
expect(

@@ -69,2 +74,51 @@ await emdaer(

});
describe('AST + CC', () => {
it('processes an .emdaer.md file', async () => {
EmdaerFeatureFlags.enableASTAndCommonComment = true;
expect(
await emdaer(
'./.emdaer/README.emdaer.md',
`# <!--emdaer-p
- '@emdaer/plugin-foo'
- a: 0
b: 1
c: 2
-->
<!--emdaer-t
- '@emdaer/transform-bar'
-->
`
)
).toBe(`<!--
This file was generated by emdaer
Its template can be found at ./.emdaer/README.emdaer.md
-->
<h1>Hello, World!</h1>
`);
});
it('processes an .emdaer.md file without a stamp', async () => {
EmdaerFeatureFlags.enableASTAndCommonComment = true;
expect(
await emdaer(
'./.emdaer/README.emdaer.md',
`# <!--emdaer-p
- '@emdaer/plugin-foo'
- a: 0
b: 1
c: 2
-->
<!--emdaer-t
- '@emdaer/transform-bar'
-->
`,
false
)
).toBe(`<h1>Hello, World!</h1>
`);
});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc