@microsoft/atlas-css 4.0.0 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/tokens/index.js CHANGED
@@ -1,4 +1,4 @@
1
- const fs = require('fs-extra');
1
+ const { readFile, writeFile, mkdir } = require('fs/promises');
2
2
  const path = require('path');
3
3
  const { quicktype, InputData, jsonInputForTargetLanguage } = require('quicktype-core');
4
4
  const { exporter } = require('sass-export');
@@ -24,9 +24,9 @@ async function createTokens() {
24
24
  const outfileStem = path.join(outfolder, 'tokens');
25
25
 
26
26
  try {
27
- await fs.ensureDir(outfolder);
27
+ await mkdir(outfolder, { recursive: true });
28
28
  await Promise.all([
29
- fs.writeJSON(`${outfileStem}.json`, collection),
29
+ writeFile(`${outfileStem}.json`, JSON.stringify(collection)),
30
30
  quicktypeJSON('AtlasTokens', JSON.stringify(collection), `${outfileStem}.ts`, 'typescript')
31
31
  ]);
32
32
  console.log(`Tokens written to "${path.join(process.cwd(), `/dist/${outfileStem}.json`)}".`);
@@ -45,7 +45,7 @@ async function getInputFilesFromIndex(filePathStem, indexPath) {
45
45
  /** @type {string[]} */
46
46
  const filePaths = [];
47
47
  try {
48
- const indexFile = (await fs.readFile(indexPath)).toString();
48
+ const indexFile = (await readFile(indexPath)).toString();
49
49
  const lines = indexFile.split('\n').reduce((arr, line) => {
50
50
  if (line.includes('@import')) {
51
51
  const filePath = line.replace('@import', '').replaceAll(`'`, '').replace(';', '').trim();
@@ -66,7 +66,7 @@ async function getInputFilesFromIndex(filePathStem, indexPath) {
66
66
  function checkFileComments(paths) {
67
67
  const promises = paths.map(async path => {
68
68
  try {
69
- const result = await fs.readFile(path, 'utf8');
69
+ const result = await readFile(path, 'utf8');
70
70
  if (!result.includes('@sass-export-section')) {
71
71
  console.log(`Warning: ${path} is missing @sass-export-section annotations.`);
72
72
  }
@@ -242,5 +242,5 @@ async function quicktypeJSON(typeName, jsonString, outfile, targetLanguage = 'ty
242
242
  inputData,
243
243
  lang: targetLanguage
244
244
  });
245
- return fs.writeFile(outfile, result.lines.join('\n'));
245
+ return writeFile(outfile, result.lines.join('\n'));
246
246
  }