@@ -8,9 +8,8 @@ import { describe } from 'mocha'
88import assert from 'assert'
99import * as path from 'path'
1010import { platform } from 'os'
11- // import { existsSync, mkdirSync, unlinkSync, writeFileSync } from 'fs'
11+ import { existsSync , mkdirSync , unlinkSync , writeFileSync } from 'fs' // eslint-disable-line no-restricted-imports
1212import { runCmd } from './testUtils'
13- import { fs } from '../shared'
1413
1514/**
1615 * NOTES:
@@ -41,22 +40,22 @@ describe('git-secrets', function () {
4140 } )
4241 }
4342
44- async function setupTestFixturesDir ( toolkitProjectDir : string ) {
43+ function setupTestFixturesDir ( toolkitProjectDir : string ) {
4544 const testFixturesPath = path . join ( toolkitProjectDir , 'src' , 'testFixtures' , 'bin' )
46- await fs . mkdir ( testFixturesPath )
45+ mkdirSync ( testFixturesPath , { recursive : true } )
4746 return testFixturesPath
4847 }
4948
50- async function setupAccessKeyFile ( testFixturesPath : string ) {
49+ function setupAccessKeyFile ( testFixturesPath : string ) {
5150 const accessKeyFilePath = path . join ( testFixturesPath , 'fileWithAccessKey.ts' )
52- await deleteFileIfExists ( accessKeyFilePath )
51+ deleteFileIfExists ( accessKeyFilePath )
5352 return accessKeyFilePath
5453 }
5554
56- async function setupGitSecretsExecutable ( testFixturesPath : string ) {
55+ function setupGitSecretsExecutable ( testFixturesPath : string ) {
5756 const gitSecretsExecutablePath = path . join ( testFixturesPath , 'git-secrets' )
5857
59- if ( await fs . exists ( gitSecretsExecutablePath ) ) {
58+ if ( existsSync ( gitSecretsExecutablePath ) ) {
6059 console . log ( 'INFO: git-secrets already installed' )
6160 } else {
6261 console . log ( 'INFO: Installing git-secrets...' )
@@ -73,13 +72,13 @@ describe('git-secrets', function () {
7372 return gitSecretsExecutablePath
7473 }
7574
76- async function deleteFileIfExists ( filePath : string ) {
77- if ( await fs . exists ( filePath ) ) {
78- await fs . delete ( filePath )
75+ function deleteFileIfExists ( filePath : string ) {
76+ if ( existsSync ( filePath ) ) {
77+ unlinkSync ( filePath )
7978 }
8079 }
8180
82- async function createFileWithSecretKey ( accessKeyFilePath : string ) {
81+ function createFileWithSecretKey ( accessKeyFilePath : string ) {
8382 // Create file in project that has secret key value.
8483 // Need to build access key string incrementally to not trigger git-secrets.
8584 const keyValue = 'yAki21XLhAIBiKvyaxr4p/ltr8OxkZTHISISFAKE'
@@ -92,36 +91,36 @@ describe('git-secrets', function () {
9291
9392${ mySecretAccessKey }
9493` . trim ( )
95- await fs . writeFile ( accessKeyFilePath , fileContent )
94+ writeFileSync ( accessKeyFilePath , fileContent )
9695 }
9796
98- before ( async function ( ) {
97+ before ( function ( ) {
9998 if ( platform ( ) === 'win32' ) {
10099 this . skip ( )
101100 }
102101
103102 toolkitProjectDir = path . resolve ( )
104- testFixturesPath = await setupTestFixturesDir ( toolkitProjectDir )
105- gitSecrets = await setupGitSecretsExecutable ( testFixturesPath )
106- accessKeyFilePath = await setupAccessKeyFile ( testFixturesPath )
103+ testFixturesPath = setupTestFixturesDir ( toolkitProjectDir )
104+ gitSecrets = setupGitSecretsExecutable ( testFixturesPath )
105+ accessKeyFilePath = setupAccessKeyFile ( testFixturesPath )
107106
108107 // Register all patterns with `git-secrets`
109108 runCmd ( [ gitSecrets , '--register-aws' ] , { cwd : toolkitProjectDir } )
110109 setDenyListPatterns ( gitSecrets )
111110 setAllowListPatterns ( gitSecrets )
112111 } )
113112
114- afterEach ( async function ( ) {
115- await deleteFileIfExists ( accessKeyFilePath )
113+ afterEach ( function ( ) {
114+ deleteFileIfExists ( accessKeyFilePath )
116115 } )
117116
118117 it ( 'ensures no git secrets are found' , function ( ) {
119118 const result = runCmd ( [ gitSecrets , '--scan' ] , { cwd : toolkitProjectDir } )
120119 assert . strictEqual ( result . status , 0 , `Failure output: ${ result . stderr . toString ( ) } ` )
121120 } )
122121
123- it ( 'sanity check it finds secrets' , async function ( ) {
124- await createFileWithSecretKey ( accessKeyFilePath )
122+ it ( 'sanity check it finds secrets' , function ( ) {
123+ createFileWithSecretKey ( accessKeyFilePath )
125124 const result = runCmd ( [ gitSecrets , '--scan' , accessKeyFilePath ] , { cwd : toolkitProjectDir , throws : false } )
126125 assert . strictEqual ( result . status , 1 )
127126 } )
0 commit comments