-
-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into release/4.0
- Loading branch information
Showing
5 changed files
with
68 additions
and
2 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
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,38 @@ | ||
#!/usr/bin/env node | ||
const recast = require('recast'); | ||
const { builders: b } = require('ast-types'); | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
const pkg = require('../package.json'); | ||
|
||
const target = path.join(__dirname, '..', 'src', 'rulesets', 'finder.ts'); | ||
|
||
const source = fs.readFileSync(target, 'utf8'); | ||
const ast = recast.parse(source, { | ||
parser: require('recast/parsers/typescript'), | ||
}); | ||
|
||
const { | ||
program: { body }, | ||
} = ast; | ||
|
||
for (const node of body) { | ||
if (node.type === 'FunctionDeclaration' && node.id.name === 'resolveSpectralVersion') { | ||
node.body.body = [ | ||
b.returnStatement( | ||
b.callExpression( | ||
b.memberExpression( | ||
b.callExpression(b.identifier('String'), [b.identifier(node.params[0].name)]), | ||
b.identifier('replace'), | ||
), | ||
[ | ||
b.stringLiteral(pkg.name), | ||
b.stringLiteral(`${pkg.name}@${pkg.version}`), | ||
] | ||
) | ||
), | ||
]; | ||
} | ||
} | ||
|
||
fs.writeFileSync(target, recast.print(ast, { quote: 'single' }).code); |
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