1- import { promises as fs } from 'fs'
1+ import { existsSync , promises as fs } from 'fs'
22import { fileURLToPath } from 'url'
33
44import { Fixture , normalizeOutput } from '@netlify/testing'
55import test from 'ava'
66import del from 'del'
7- import { pathExists } from 'path-exists'
87
98import { updateConfig } from '../../lib/main.js'
109
@@ -50,19 +49,19 @@ const initFixtureDir = async function (fixtureName) {
5049// Create temporary copies of `netlify.toml` and `redirects` from the fixture
5150// directory to use in tests
5251const copyIfExists = async function ( fixturePath , tempPath ) {
53- if ( await pathExists ( fixturePath ) ) {
52+ if ( existsSync ( fixturePath ) ) {
5453 await fs . copyFile ( fixturePath , tempPath )
5554 return
5655 }
5756
58- if ( await pathExists ( tempPath ) ) {
57+ if ( existsSync ( tempPath ) ) {
5958 await del ( tempPath )
6059 }
6160}
6261
6362test ( 'updateConfig() saves netlify.toml' , async ( t ) => {
6463 const { configPath } = await runUpdateConfig ( 'save' )
65- t . true ( await pathExists ( configPath ) )
64+ t . true ( existsSync ( configPath ) )
6665} )
6766
6867test ( 'updateConfig() updates the configuration so it can be read again' , async ( t ) => {
@@ -73,7 +72,7 @@ test('updateConfig() updates the configuration so it can be read again', async (
7372
7473test ( 'updateConfig() is a noop when where are no config mutations' , async ( t ) => {
7574 const { configPath } = await runUpdateConfig ( 'noop' , { configMutations : [ ] } )
76- t . false ( await pathExists ( configPath ) )
75+ t . false ( existsSync ( configPath ) )
7776} )
7877
7978test ( 'updateConfig() has higher priority than context properties' , async ( t ) => {
@@ -91,19 +90,19 @@ test('updateConfig() merges with the existing netlify.toml', async (t) => {
9190test ( 'updateConfig() deletes _redirects when redirects were changed' , async ( t ) => {
9291 const { redirectsPath } = await runUpdateConfig ( 'redirects_change' , { configMutations : [ redirectsMutation ] } )
9392 t . is ( typeof redirectsPath , 'string' )
94- t . false ( await pathExists ( redirectsPath ) )
93+ t . false ( existsSync ( redirectsPath ) )
9594} )
9695
9796test ( 'updateConfig() deletes _redirects on changes even if redirects were not changed' , async ( t ) => {
9897 const { redirectsPath } = await runUpdateConfig ( 'redirects_no_change' )
9998 t . is ( typeof redirectsPath , 'string' )
100- t . false ( await pathExists ( redirectsPath ) )
99+ t . false ( existsSync ( redirectsPath ) )
101100} )
102101
103102test ( 'updateConfig() does not delete _redirects if it does not exist' , async ( t ) => {
104103 const { redirectsPath } = await runUpdateConfig ( 'redirects_none' )
105104 t . is ( typeof redirectsPath , 'string' )
106- t . false ( await pathExists ( redirectsPath ) )
105+ t . false ( existsSync ( redirectsPath ) )
107106} )
108107
109108test ( 'updateConfig() does not delete _redirects if redirectsPath not provided' , async ( t ) => {
@@ -112,25 +111,25 @@ test('updateConfig() does not delete _redirects if redirectsPath not provided',
112111 redirectsPath : undefined ,
113112 } )
114113 t . is ( typeof redirectsPath , 'string' )
115- t . true ( await pathExists ( redirectsPath ) )
114+ t . true ( existsSync ( redirectsPath ) )
116115} )
117116
118117test ( 'updateConfig() deletes _headers when headers were changed' , async ( t ) => {
119118 const { headersPath } = await runUpdateConfig ( 'headers_change' , { configMutations : [ headersMutation ] } )
120119 t . is ( typeof headersPath , 'string' )
121- t . false ( await pathExists ( headersPath ) )
120+ t . false ( existsSync ( headersPath ) )
122121} )
123122
124123test ( 'updateConfig() deletes _headers on changes even if headers were not changed' , async ( t ) => {
125124 const { headersPath } = await runUpdateConfig ( 'headers_no_change' )
126125 t . is ( typeof headersPath , 'string' )
127- t . false ( await pathExists ( headersPath ) )
126+ t . false ( existsSync ( headersPath ) )
128127} )
129128
130129test ( 'updateConfig() does not delete _headers if it does not exist' , async ( t ) => {
131130 const { headersPath } = await runUpdateConfig ( 'headers_none' )
132131 t . is ( typeof headersPath , 'string' )
133- t . false ( await pathExists ( headersPath ) )
132+ t . false ( existsSync ( headersPath ) )
134133} )
135134
136135test ( 'updateConfig() does not delete _headers if headersPath not provided' , async ( t ) => {
@@ -139,5 +138,5 @@ test('updateConfig() does not delete _headers if headersPath not provided', asyn
139138 headersPath : undefined ,
140139 } )
141140 t . is ( typeof headersPath , 'string' )
142- t . true ( await pathExists ( headersPath ) )
141+ t . true ( existsSync ( headersPath ) )
143142} )
0 commit comments