-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(adapters.nestjs): add post install script
Add post install script to apply the nestjs adapter to @automock/common
- Loading branch information
Showing
2 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
const filePath = path.join(__dirname, '..', 'common', 'typings.d.ts'); | ||
const newContent = "\nexport type IdentifierMetadata = import('@automock/adapters.nestjs').IdentifierMetadata;\n"; | ||
|
||
fs.readFile(filePath, 'utf8', function (err, data) { | ||
console.log('Automock: attempting to override @automock/common typings file') | ||
|
||
if (err) { | ||
console.log('Automock: an error occurred while reading @automock/common typings file') | ||
return console.error(err); | ||
} | ||
|
||
const updatedData = data + newContent; | ||
|
||
fs.writeFile(filePath, updatedData, 'utf8', function (err) { | ||
if (err) { | ||
console.log('Automock: an error occurred while writing to @automock/common typings file') | ||
return console.log(err); | ||
} | ||
|
||
console.log('Automock: @automock/common typings file updated with successfully with the proper Automock adapter') | ||
}); | ||
}); |