文件操作 - extract-namespaces-to-root.js
返回文件管理
返回主菜单
删除本文件
文件: /var/www/OLD/node_modules/svg-baker/lib/transformations/extract-namespaces-to-root.js
编辑文件内容
const { getRoot } = require('../utils'); /** * @return {Function} PostHTML plugin */ function extractNamespacesToRoot() { return (tree) => { const namespaces = {}; tree.match({ tag: /.*/ }, (node) => { const attrs = node.attrs || {}; Object.keys(attrs).forEach((attr) => { if (attr.startsWith('xmlns')) { if (attr in namespaces === false) { namespaces[attr] = attrs[attr]; } delete node.attrs[attr]; } }); return node; }); const root = getRoot(tree); root.attrs = root.attrs || {}; Object.keys(namespaces).forEach(name => root.attrs[name] = namespaces[name]); return tree; }; } module.exports = extractNamespacesToRoot;
修改文件时间
将文件时间修改为当前时间的前一年
删除文件