@@ -8,6 +8,10 @@ const markdown = require('..')
88const expandWildcardKeypath = require ( '../lib/expand-wildcard-keypath' )
99const path = require ( 'path' )
1010
11+ function msCommon ( dir ) {
12+ return Metalsmith ( dir ) . env ( 'DEBUG' , process . env . DEBUG )
13+ }
14+
1115describe ( '@metalsmith/markdown' , function ( ) {
1216 it ( 'should export a named plugin function matching package.json name' , function ( ) {
1317 const namechars = name . split ( '/' ) [ 1 ]
@@ -19,8 +23,7 @@ describe('@metalsmith/markdown', function () {
1923 } )
2024
2125 it ( 'should not crash the metalsmith build when using default options' , function ( done ) {
22- Metalsmith ( 'test/fixtures/default' )
23- . env ( 'DEBUG' , process . env . DEBUG )
26+ msCommon ( 'test/fixtures/default' )
2427 . use ( markdown ( ) )
2528 . build ( ( err ) => {
2629 assert . strictEqual ( err , null )
@@ -42,19 +45,19 @@ describe('@metalsmith/markdown', function () {
4245 Promise . all ( [
4346 new Promise ( ( resolve ) => {
4447 const files = getFiles ( )
45- markdown ( true ) ( files , Metalsmith ( __dirname ) , ( ) => {
48+ markdown ( true ) ( files , msCommon ( __dirname ) , ( ) => {
4649 resolve ( files )
4750 } )
4851 } ) ,
4952 new Promise ( ( resolve ) => {
5053 const files = getFiles ( )
51- markdown ( ) ( files , Metalsmith ( __dirname ) , ( ) => {
54+ markdown ( ) ( files , msCommon ( __dirname ) , ( ) => {
5255 resolve ( files )
5356 } )
5457 } ) ,
5558 new Promise ( ( resolve ) => {
5659 const files = getFiles ( )
57- markdown ( { smartypants : true } ) ( files , Metalsmith ( __dirname ) , ( ) => {
60+ markdown ( { smartypants : true } ) ( files , msCommon ( __dirname ) , ( ) => {
5861 resolve ( files )
5962 } )
6063 } )
@@ -70,8 +73,7 @@ describe('@metalsmith/markdown', function () {
7073 } )
7174
7275 it ( 'should convert markdown files' , function ( done ) {
73- Metalsmith ( 'test/fixtures/basic' )
74- . env ( 'DEBUG' , process . env . DEBUG )
76+ msCommon ( 'test/fixtures/basic' )
7577 . use (
7678 markdown ( {
7779 smartypants : true
@@ -86,15 +88,14 @@ describe('@metalsmith/markdown', function () {
8688
8789 it ( 'should skip non-markdown files' , function ( done ) {
8890 const files = { 'index.css' : { } }
89- markdown ( true ) ( files , Metalsmith ( __dirname ) , ( ) => {
91+ markdown ( true ) ( files , msCommon ( __dirname ) , ( ) => {
9092 assert . deepStrictEqual ( files , { 'index.css' : { } } )
9193 done ( )
9294 } )
9395 } )
9496
9597 it ( 'should allow a "keys" option' , function ( done ) {
96- Metalsmith ( 'test/fixtures/keys' )
97- . env ( 'DEBUG' , process . env . DEBUG )
98+ msCommon ( 'test/fixtures/keys' )
9899 . use (
99100 markdown ( {
100101 keys : [ 'custom' ] ,
@@ -109,8 +110,7 @@ describe('@metalsmith/markdown', function () {
109110 } )
110111
111112 it ( 'should parse nested key paths' , function ( done ) {
112- Metalsmith ( 'test/fixtures/nested-keys' )
113- . env ( 'DEBUG' , process . env . DEBUG )
113+ msCommon ( 'test/fixtures/nested-keys' )
114114 . use (
115115 markdown ( {
116116 keys : [ 'custom' , 'nested.key.path' ] ,
@@ -143,8 +143,7 @@ describe('@metalsmith/markdown', function () {
143143 } )
144144
145145 it ( 'should recognize a keys option loop placeholder' , function ( done ) {
146- Metalsmith ( 'test/fixtures/array-index-keys' )
147- . env ( 'DEBUG' , process . env . DEBUG )
146+ msCommon ( 'test/fixtures/array-index-keys' )
148147 . use (
149148 markdown ( {
150149 keys : [ 'arr.*' , 'objarr.*.prop' , 'wildcard.faq.*.*' , 'wildcard.titles.*' ] ,
0 commit comments