@davidlj95/ngx-meta
Version:
Set your Angular site's metadata: standard meta tags, Open Graph, Twitter Cards, JSON-LD structured data and more. Supports SSR (and Angular Universal). Use a service. Use routes' data. Set it up in a flash! 🚀
25 lines • 1.24 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.applyChanges = void 0;
const change_1 = require("../external-utils/schematics/angular/utility/change");
const applyChanges = (tree, path, changes) => {
const updateRecorder = tree.beginUpdate(path);
(0, change_1.applyToUpdateRecorder)(updateRecorder, sortChangesByDescendingPosition(changes));
tree.commitUpdate(updateRecorder);
};
exports.applyChanges = applyChanges;
/**
* Sorts changes to apply to a file by position in the file in descending order.
* So changes are applied from end to start of the file.
*
* This is important, as if applying changes in any order, it can happen that changes are messed up.
* For instance, if removing some characters first, and then applying a replacement later.
* If later replacement doesn't take into account that position has been updated due to the delete,
* Then the actual replacement performed won't be the expected one.
*
* See:
*
* - https://github.com/angular/angular/blob/18.2.9/packages/core/schematics/utils/change_tracker.ts#L187-L189
*/
const sortChangesByDescendingPosition = (changes) => changes.sort((a, b) => a.order - b.order);
//# sourceMappingURL=apply-changes.js.map
;