pathstringobligatoireLe dossier.
editsarrayobligatoireChacun avec old_string, new_string et facultativement replace_all.
Tout ou rien
Si un remplacement ne peut être effectué, aucun d'eux n'est écrit. Un fichier n'est jamais laissé à mi-chemin — ce qui importe lorsque les changements dépendent l'un de l'autre, comme le fait un renommer à travers un fichier.
En ordre, et qui est visible
Ainsi, un remplacement antérieur peut créer — ou détruire — le texte que l'on recherche plus tard. Énumérez-les dans l'ordre où ils apparaissent dans le fichier et gardez leurs contextes distincts.
{
path: "src/auth.js",
edits: [
{ old_string: "const TTL = 3600", new_string: "const TTL = 900" },
{ old_string: "// TODO: rotate", new_string: "// rotated on refresh" },
{ old_string: "oldName", new_string: "newName", replace_all: true }
]
}{
"path": "src/auth.js",
"edits": [
{"old_string": "const TTL = 3600", "new_string": "const TTL = 900"},
{"old_string": "// TODO: rotate", "new_string": "// rotated on refresh"},
{"old_string": "oldName", "new_string": "newName", "replace_all": True},
],
}Quand c'est le bon outil
Un renommer à travers un fichier, un ensemble de modifications connexes, en appliquant ce qu'un Grêpe Dans plusieurs fichiers, il y a un appel à chacun — il n'y a pas de modification multi-fichier.