Home / File/ create-test.js — svelte Source File

create-test.js — svelte Source File

Architecture documentation for create-test.js, a javascript file in the svelte codebase. 3 imports, 0 dependents.

File javascript Compiler Parser 3 imports 2 functions

Entity Profile

Dependency Diagram

graph LR
  ac45616b_3001_c007_15a3_9896c87b0ad4["create-test.js"]
  89cf2c52_8705_f8b2_5c62_c0ddd60e45be["fs"]
  ac45616b_3001_c007_15a3_9896c87b0ad4 --> 89cf2c52_8705_f8b2_5c62_c0ddd60e45be
  8e876fd7_e6ba_9c20_16bc_6032ae8299a3["path"]
  ac45616b_3001_c007_15a3_9896c87b0ad4 --> 8e876fd7_e6ba_9c20_16bc_6032ae8299a3
  3f40c5e4_fd94_459d_3787_cf47f933a771["url"]
  ac45616b_3001_c007_15a3_9896c87b0ad4 --> 3f40c5e4_fd94_459d_3787_cf47f933a771
  style ac45616b_3001_c007_15a3_9896c87b0ad4 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

// Creates a test from the existing playground. Can be called from anywhere.
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';

// Get the directory where this script is located
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

// Base paths relative to this script's location
const sandbox_dir = path.resolve(__dirname, '..');
const src_dir = path.join(sandbox_dir, 'src');
const tests_dir = path.resolve(__dirname, '../../../packages/svelte/tests');

// Get target folder from command line arguments
let target_folder = process.argv[2];
if (!target_folder) {
	console.error(
		'Please provide a target folder as an argument. Example: node create-test.js runtime-runes/my-test'
	);
	process.exit(1);
}
if (!target_folder.includes('/')) {
	target_folder = 'runtime-runes/' + target_folder;
}
if (!target_folder.startsWith('runtime-')) {
	console.error(
		'Target folder must start with "runtime-" (can only convert to these kinds of tests)'
	);
	process.exit(1);
}
target_folder = path.join(
	path.resolve(tests_dir, target_folder.split('/')[0]),
	'samples',
	target_folder.split('/')[1]
);

const exists = fs.existsSync(target_folder);

// Check if target folder already exists and ask for confirmation
if (exists) {
	console.log(`Target folder "${target_folder}" already exists.`);
	process.stdout.write('Do you want to override the existing test? (Y/n): ');

	// Read user input synchronously
	const stdin = process.stdin;
	stdin.setRawMode(true);
	stdin.resume();
	stdin.setEncoding('utf8');

	const response = await new Promise((resolve) => {
		stdin.on('data', (key) => {
			stdin.setRawMode(false);
			stdin.pause();
			process.stdout.write('\n');
			resolve(key);
		});
	});

	if (response.toLowerCase() === 'n') {
// ... (106 more lines)

Domain

Subdomains

Dependencies

  • fs
  • path
  • url

Frequently Asked Questions

What does create-test.js do?
create-test.js is a source file in the svelte codebase, written in javascript. It belongs to the Compiler domain, Parser subdomain.
What functions are defined in create-test.js?
create-test.js defines 2 function(s): collect_imports, response.
What does create-test.js depend on?
create-test.js imports 3 module(s): fs, path, url.
Where is create-test.js in the architecture?
create-test.js is located at playgrounds/sandbox/scripts/create-test.js (domain: Compiler, subdomain: Parser, directory: playgrounds/sandbox/scripts).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free