/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ import { sep } from "node:path"; import { getLayerString } from "../desktop-format/get-layer-string.mjs"; const getFileName = file => { if (!file || file.destination.startsWith("dist/")) { return "the relevant *.tokens.json file"; } // Windows file separators can end up mixed with forward slashes in these paths, so we check for them as well const cssFileName = file.destination.split("/").at(-1).split(sep).at(-1); return cssFileName.replace(".css", ".json"); }; export const customFileHeader = ({ surface, platform, file }) => { const licenseString = `/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */`; const commentString = `/* DO NOT EDIT this file directly, instead modify ${getFileName(file)} * and run \`mach buildtokens\` to see your changes. */`; const cssImport = surface ? `@import url("chrome://global/skin/design-system/tokens-shared.css");\n\n` : ""; const layerString = !surface && !platform ? getLayerString() : ""; return `${licenseString} ${commentString} ${cssImport}${layerString}`; };