1- const fs = require ( 'fs' )
1+ const fs = require ( 'fs' ) . promises
22const path = require ( 'path' )
33const cheerio = require ( 'cheerio' )
44const matter = require ( 'gray-matter' )
@@ -35,8 +35,8 @@ function processFrontmatter (contents, file) {
3535}
3636
3737describe ( 'removing liquid statements only' , ( ) => {
38- test ( 'removes liquid statements that specify "greater than version to deprecate"' , ( ) => {
39- let contents = fs . readFileSync ( greaterThan , 'utf8' )
38+ test ( 'removes liquid statements that specify "greater than version to deprecate"' , async ( ) => {
39+ let contents = await fs . readFile ( greaterThan , 'utf8' )
4040 contents = removeLiquidStatements ( contents , versionToDeprecate , nextOldestVersion )
4141 const $ = cheerio . load ( contents )
4242 expect ( $ ( '.example1' ) . text ( ) . trim ( ) ) . toBe ( 'Alpha' )
@@ -57,8 +57,8 @@ Alpha\n\n{% else %}\n\nBravo\n\n{% if currentVersion ver_gt "enterprise-server@2
5757 expect ( $ ( '.example10' ) . text ( ) . trim ( ) ) . toBe ( 'Alpha' )
5858 } )
5959
60- test ( 'removes liquid statements that specify "and greater than version to deprecate"' , ( ) => {
61- let contents = fs . readFileSync ( andGreaterThan1 , 'utf8' )
60+ test ( 'removes liquid statements that specify "and greater than version to deprecate"' , async ( ) => {
61+ let contents = await fs . readFile ( andGreaterThan1 , 'utf8' )
6262 contents = removeLiquidStatements ( contents , versionToDeprecate , nextOldestVersion )
6363 const $ = cheerio . load ( contents )
6464 expect ( $ ( '.example1' ) . text ( ) . trim ( ) ) . toBe ( '{% if currentVersion != "free-pro-team@latest" %}\n\nAlpha\n\n{% endif %}' )
@@ -71,8 +71,8 @@ Alpha\n\n{% if currentVersion != "free-pro-team@latest" %}\n\nBravo\n\n{% endif
7171Alpha\n\n{% if currentVersion ver_gt "enterprise-server@2.16" %}\n\nBravo\n\n{% endif %}\n\n{% endif %}` )
7272 } )
7373
74- test ( 'removes liquid statements that specify "and greater than version to deprecate" (alternate format)' , ( ) => {
75- let contents = fs . readFileSync ( andGreaterThan2 , 'utf8' )
74+ test ( 'removes liquid statements that specify "and greater than version to deprecate" (alternate format)' , async ( ) => {
75+ let contents = await fs . readFile ( andGreaterThan2 , 'utf8' )
7676 contents = removeLiquidStatements ( contents , versionToDeprecate , nextOldestVersion )
7777 const $ = cheerio . load ( contents )
7878 expect ( $ ( '.example1' ) . text ( ) . trim ( ) ) . toBe ( '{% if currentVersion ver_lt "enterprise-server@2.16" %}\n\nAlpha\n\n{% endif %}' )
@@ -85,8 +85,8 @@ Alpha\n\n{% if currentVersion ver_lt "enterprise-server@2.16" %}\n\nBravo\n\n{%
8585Alpha\n\n{% if currentVersion != "free-pro-team@latest" %}\n\nBravo\n\n{% endif %}\n\n{% endif %}` )
8686 } )
8787
88- test ( 'removes liquid statements that specify "not equals version to deprecate"' , ( ) => {
89- let contents = fs . readFileSync ( notEquals , 'utf8' )
88+ test ( 'removes liquid statements that specify "not equals version to deprecate"' , async ( ) => {
89+ let contents = await fs . readFile ( notEquals , 'utf8' )
9090 contents = removeLiquidStatements ( contents , versionToDeprecate , nextOldestVersion )
9191 const $ = cheerio . load ( contents )
9292 expect ( $ ( '.example1' ) . text ( ) . trim ( ) ) . toBe ( 'Alpha' )
@@ -103,8 +103,8 @@ Alpha\n\n{% endif %}`)
103103} )
104104
105105describe ( 'removing liquid statements and content' , ( ) => {
106- test ( 'removes interior content and liquid statements that specify "equals version to deprecate"' , ( ) => {
107- let contents = fs . readFileSync ( equals , 'utf8' )
106+ test ( 'removes interior content and liquid statements that specify "equals version to deprecate"' , async ( ) => {
107+ let contents = await fs . readFile ( equals , 'utf8' )
108108 contents = removeLiquidStatements ( contents , versionToDeprecate , nextOldestVersion )
109109 const $ = cheerio . load ( contents )
110110 expect ( $ ( '.example1' ) . text ( ) . trim ( ) ) . toBe ( '' )
@@ -117,8 +117,8 @@ Alpha\n\n{% else %}\n\nCharlie\n\n{% endif %}`)
117117 expect ( $ ( '.example6' ) . text ( ) . trim ( ) ) . toBe ( 'Charlie\n\nBravo' )
118118 } )
119119
120- test ( 'removes interior content and liquid statements that specify "less than next oldest than version to deprecate"' , ( ) => {
121- let contents = fs . readFileSync ( lessThanNextOldest , 'utf8' )
120+ test ( 'removes interior content and liquid statements that specify "less than next oldest than version to deprecate"' , async ( ) => {
121+ let contents = await fs . readFile ( lessThanNextOldest , 'utf8' )
122122 contents = removeLiquidStatements ( contents , versionToDeprecate , nextOldestVersion )
123123 const $ = cheerio . load ( contents )
124124 expect ( $ ( '.example1' ) . text ( ) . trim ( ) ) . toBe ( 'Alpha' )
@@ -137,8 +137,8 @@ Charlie\n\n{% else %}\n\nDelta\n\n{% endif %}\n\nEcho`)
137137} )
138138
139139describe ( 'updating frontmatter' , ( ) => {
140- test ( 'updates frontmatter versions Enterprise if set to greater-than-or-equal-to version to deprecate' , ( ) => {
141- let contents = fs . readFileSync ( frontmatter1 , 'utf8' )
140+ test ( 'updates frontmatter versions Enterprise if set to greater-than-or-equal-to version to deprecate' , async ( ) => {
141+ let contents = await fs . readFile ( frontmatter1 , 'utf8' )
142142 contents = processFrontmatter ( contents , frontmatter1 )
143143 const $ = cheerio . load ( contents )
144144 // console.log('foo')
@@ -147,8 +147,8 @@ describe('updating frontmatter', () => {
147147 expect ( $ . text ( ) . includes ( 'enterprise-server: \'>=2.13\'' ) ) . toBe ( false )
148148 } )
149149
150- test ( 'updates frontmatter versions Enterprise if set to greater-than-or-equal-to next oldest version' , ( ) => {
151- let contents = fs . readFileSync ( frontmatter2 , 'utf8' )
150+ test ( 'updates frontmatter versions Enterprise if set to greater-than-or-equal-to next oldest version' , async ( ) => {
151+ let contents = await fs . readFile ( frontmatter2 , 'utf8' )
152152 contents = processFrontmatter ( contents , frontmatter2 )
153153 const $ = cheerio . load ( contents )
154154 expect ( $ . text ( ) . includes ( 'enterprise-server: \'*\'' ) ) . toBe ( true )
@@ -157,8 +157,8 @@ describe('updating frontmatter', () => {
157157} )
158158
159159describe ( 'whitespace' , ( ) => {
160- test ( 'does not add newlines when whitespace control is used' , ( ) => {
161- let contents = fs . readFileSync ( whitespace , 'utf8' )
160+ test ( 'does not add newlines when whitespace control is used' , async ( ) => {
161+ let contents = await fs . readFile ( whitespace , 'utf8' )
162162 contents = removeLiquidStatements ( contents , versionToDeprecate , nextOldestVersion )
163163 const $ = cheerio . load ( contents )
164164 expect ( $ ( '.example1' ) . text ( ) ) . toBe ( '\n Alpha\n' )
@@ -167,8 +167,8 @@ describe('whitespace', () => {
167167 expect ( $ ( '.example4' ) . text ( ) ) . toBe ( '\n Alpha\n' )
168168 } )
169169
170- test ( 'does not add newlines when no newlines are present' , ( ) => {
171- let contents = fs . readFileSync ( whitespace , 'utf8' )
170+ test ( 'does not add newlines when no newlines are present' , async ( ) => {
171+ let contents = await fs . readFile ( whitespace , 'utf8' )
172172 contents = removeLiquidStatements ( contents , versionToDeprecate , nextOldestVersion )
173173 const $ = cheerio . load ( contents )
174174 expect ( $ ( '.example5' ) . text ( ) ) . toBe ( '\n Alpha\n' )
0 commit comments