Skip to content

Commit

Permalink
refactor(scripts): remove deprecated exec abstractions (#25569)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hotell authored Nov 10, 2022
1 parent d1228a1 commit 63c8aa4
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 92 deletions.
23 changes: 0 additions & 23 deletions scripts/exec-sync.js

This file was deleted.

53 changes: 0 additions & 53 deletions scripts/exec.js

This file was deleted.

6 changes: 4 additions & 2 deletions scripts/lint-staged/eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
const fs = require('fs');
const os = require('os');
const path = require('path');
const { promisify } = require('util');
const child_process = require('child_process');
const { rollup: lernaAliases } = require('lerna-alias');
const { default: PQueue } = require('p-queue');
const exec = require('../exec');
const exec = promisify(child_process.exec);

const eslintForPackageScript = path.join(__dirname, 'eslint-for-package.js');

Expand Down Expand Up @@ -60,7 +62,7 @@ async function runEslintOnFilesGroupedPerPackage() {
Object.entries(filesGroupedByPackage).map(([packagePath, files]) => async () => {
// This script handles running eslint on ONLY the appropriate files for each package.
// See its comments for more details.
return exec(`node ${eslintForPackageScript} ${files.join(' ')}`, undefined, packagePath, process).catch(() => {
return exec(`node ${eslintForPackageScript} ${files.join(' ')}`, { cwd: packagePath }).catch(() => {
// The subprocess should already have handled logging. Just mark that there was an error.
hasError = true;
});
Expand Down
4 changes: 2 additions & 2 deletions scripts/local-codepen.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const WebpackDevServer = require('webpack-dev-server');
const path = require('path');
const fs = require('fs');
const yargs = require('yargs');
const execSync = require('./exec-sync');
const { execSync } = require('child_process');
const { findGitRoot } = require('./monorepo/index');
const chalk = require('chalk');

Expand All @@ -19,7 +19,7 @@ if (fs.existsSync(configPath)) {
try {
console.log("Attempting to npm link globally installed ngrok so it can be require'd");
// This will probably install ngrok globally if it's not already present
execSync('npm link ngrok@3', undefined, gitRoot);
execSync('npm link ngrok@3', { cwd: gitRoot, stdio: 'inherit' });
// @ts-expect-error - no types for ngrok
ngrok = require('ngrok');
} catch (err) {
Expand Down
4 changes: 2 additions & 2 deletions scripts/tasks/webpack.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { webpackCliTask, argv, logger } from 'just-scripts';
import * as path from 'path';
import * as fs from 'fs';
import execSync from '../exec-sync';
import { execSync } from 'child_process';
import { getJustArgv } from './argv';

export function webpack() {
Expand Down Expand Up @@ -48,7 +48,7 @@ export function webpackDevServer(

process.env.cached = String(args.cached);

execSync(cmd);
execSync(cmd, { stdio: 'inherit' });
}
};
}
23 changes: 13 additions & 10 deletions scripts/token-pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import path from 'path';
import * as fs from 'fs-extra';
import * as _ from 'lodash';
import * as yargs from 'yargs';
import { execSync } from 'child_process';

import { findGitRoot } from './monorepo';
import execSync from './exec-sync';
import { createTempDir } from './projects-test';

const themes = ['light', 'dark', 'teamsDark', 'highContrast'] as const;
Expand Down Expand Up @@ -34,6 +34,8 @@ function getGeneratedFiles(tmpDir: string) {
function runPipeline(theme: typeof themes[number], pipelineDir: string, outDir: string) {
console.log(`Running pipeline for ${theme} theme`);

console.log(`Generate tokens for theme`);

// https://github.com/microsoft/fluentui-token-pipeline
execSync(
[
Expand All @@ -44,8 +46,7 @@ function runPipeline(theme: typeof themes[number], pipelineDir: string, outDir:
`--in src/${_.kebabCase(theme)}.json`,
`--out ${outDir}/${theme}`,
].join(' '),
`Generate tokens for theme:${theme}`,
pipelineDir,
{ cwd: pipelineDir },
);
}

Expand All @@ -59,14 +60,15 @@ function setupDesignTokensRepo(options: { argv: typeof argv }) {
return { pipelineDir, tmpDir };
}

console.log('Clone design tokens repo');
// clone repo, install deps
execSync(
'git clone --depth 1 https://github.com/microsoft/fluentui-design-tokens.git',
'Clone design tokens repo',
tmpDir,
);
execSync('git clone --depth 1 https://github.com/microsoft/fluentui-design-tokens.git', {
cwd: tmpDir,
stdio: 'inherit',
});
const pipelineDir = path.join(tmpDir, 'fluentui-design-tokens');
execSync('npm install', 'Install dependencies', pipelineDir);
console.log('Install dependencies');
execSync('npm install', { cwd: pipelineDir, stdio: 'inherit' });

return { pipelineDir, tmpDir };
}
Expand All @@ -83,7 +85,8 @@ const tokenPipeline = () => {
fs.copySync(file.src, file.dest, { overwrite: true });
});

execSync(`npx prettier --write ${path.join(repoRoot, 'packages/react-components/react-theme/src')}`, 'Prettier');
console.log('Format');
execSync(`npx prettier --write ${path.join(repoRoot, 'packages/react-components/react-theme/src')}`);
};

tokenPipeline();

0 comments on commit 63c8aa4

Please sign in to comment.