@@ -4,13 +4,13 @@ const fs = require('node:fs').promises;
44const path = require ( 'path' ) ;
55const proxyquire = require ( 'proxyquire' ) ;
66const chai = require ( 'chai' ) ;
7- const fse = require ( 'fs-extra' ) ;
87const sinon = require ( 'sinon' ) ;
98const Context = require ( '../../../../src/Context' ) ;
109const ComponentContext = require ( '../../../../src/ComponentContext' ) ;
1110const { validateComponentInputs } = require ( '../../../../src/configuration/validate' ) ;
1211const { configSchema } = require ( '../../../../components/framework/configuration' ) ;
1312const ServerlessFramework = require ( '../../../../components/framework' ) ;
13+ const { outputFile, remove } = require ( '../../../lib/fs' ) ;
1414
1515const expect = chai . expect ;
1616
@@ -836,7 +836,7 @@ describe('test/unit/components/framework/index.test.js', () => {
836836 const serviceDir = await fs . mkdtemp ( path . join ( process . cwd ( ) , 'cache-hash-skip-' ) ) ;
837837
838838 try {
839- await fse . outputFile ( path . join ( serviceDir , 'handler.js' ) , 'module.exports = 1;\n' ) ;
839+ await outputFile ( path . join ( serviceDir , 'handler.js' ) , 'module.exports = 1;\n' ) ;
840840
841841 const spawnStub = sinon . stub ( ) ;
842842 const FrameworkComponent = proxyquire ( '../../../../components/framework/index.js' , {
@@ -857,7 +857,7 @@ describe('test/unit/components/framework/index.test.js', () => {
857857
858858 expect ( spawnStub ) . to . not . have . been . called ;
859859 } finally {
860- await fse . remove ( serviceDir ) ;
860+ await remove ( serviceDir ) ;
861861 }
862862 } ) ;
863863
@@ -866,7 +866,7 @@ describe('test/unit/components/framework/index.test.js', () => {
866866
867867 try {
868868 const filePath = path . join ( serviceDir , 'handler.js' ) ;
869- await fse . outputFile ( filePath , 'module.exports = 1;\n' ) ;
869+ await outputFile ( filePath , 'module.exports = 1;\n' ) ;
870870
871871 const spawnStub = sinon . stub ( ) ;
872872 spawnStub . onFirstCall ( ) . returns ( createSpawnExecution ( { stderr : 'deployed' } ) ) ;
@@ -891,22 +891,22 @@ describe('test/unit/components/framework/index.test.js', () => {
891891 context . state . inputs = inputs ;
892892 context . state . cacheHash = await component . calculateCacheHash ( ) ;
893893
894- await fse . outputFile ( filePath , 'module.exports = 2;\n' ) ;
894+ await outputFile ( filePath , 'module.exports = 2;\n' ) ;
895895
896896 await component . deploy ( ) ;
897897
898898 expect ( spawnStub ) . to . be . calledTwice ;
899899 expect ( context . state . cacheHash ) . to . equal ( await component . calculateCacheHash ( ) ) ;
900900 } finally {
901- await fse . remove ( serviceDir ) ;
901+ await remove ( serviceDir ) ;
902902 }
903903 } ) ;
904904
905905 it ( 'expands literal directory cache patterns when calculating hashes' , async ( ) => {
906906 const serviceDir = await fs . mkdtemp ( path . join ( process . cwd ( ) , 'cache-hash-dir-' ) ) ;
907907
908908 try {
909- await fse . outputFile ( path . join ( serviceDir , 'src' , 'handler.js' ) , 'module.exports = 1;\n' ) ;
909+ await outputFile ( path . join ( serviceDir , 'src' , 'handler.js' ) , 'module.exports = 1;\n' ) ;
910910
911911 const context = await getContext ( ) ;
912912 const directoryPatternComponent = new ServerlessFramework ( 'id' , context , {
@@ -922,7 +922,7 @@ describe('test/unit/components/framework/index.test.js', () => {
922922 await globPatternComponent . calculateCacheHash ( )
923923 ) ;
924924 } finally {
925- await fse . remove ( serviceDir ) ;
925+ await remove ( serviceDir ) ;
926926 }
927927 } ) ;
928928
@@ -931,9 +931,9 @@ describe('test/unit/components/framework/index.test.js', () => {
931931
932932 try {
933933 await Promise . all ( [
934- fse . outputFile ( path . join ( serviceDir , 'keep.js' ) , 'keep\n' ) ,
935- fse . outputFile ( path . join ( serviceDir , 'ignored' , 'drop.js' ) , 'drop\n' ) ,
936- fse . outputFile ( path . join ( serviceDir , 'ignored' , 'reinclude.js' ) , 'reinclude\n' ) ,
934+ outputFile ( path . join ( serviceDir , 'keep.js' ) , 'keep\n' ) ,
935+ outputFile ( path . join ( serviceDir , 'ignored' , 'drop.js' ) , 'drop\n' ) ,
936+ outputFile ( path . join ( serviceDir , 'ignored' , 'reinclude.js' ) , 'reinclude\n' ) ,
937937 ] ) ;
938938
939939 const context = await getContext ( ) ;
@@ -950,7 +950,7 @@ describe('test/unit/components/framework/index.test.js', () => {
950950 await explicitPatternComponent . calculateCacheHash ( )
951951 ) ;
952952 } finally {
953- await fse . remove ( serviceDir ) ;
953+ await remove ( serviceDir ) ;
954954 }
955955 } ) ;
956956} ) ;
0 commit comments