↓こんな感じに実行すると、before/after のようにピンポイントでいい感じに修正されたコードが出てくる。みたいな感じに使える。
# -d を外すと元のファイルが修正される
bunx jscodeshift -t modify-video-provider.ts sample.js -d -pbefore:
this._singleSetup = requestVideoStream({
width: {min: 480, ideal: 640},
height: {min: 360, ideal: 480}
})after:
this._singleSetup = requestVideoStream(Object.assign({
width: {min: 480, ideal: 640},
height: {min: 360, ideal: 480}
}, this.videoDescripter))@types/jscodeshift を入れておくと型が付いて快適に書けるようになる。
bun add -d @types/jscodeshift jscodeshiftAST Explorer と一緒に使うととても捗る。 https://astexplorer.net