From 2c395934ac63ba5ef7b816a3eb400ebc281298f6 Mon Sep 17 00:00:00 2001 From: mauroerta Date: Thu, 20 May 2021 14:32:22 +0200 Subject: [PATCH] fix: prettier --- .../svelte-sandbox/scripts/setupTypeScript.js | 101 ++++++++++-------- 1 file changed, 57 insertions(+), 44 deletions(-) diff --git a/apps/svelte-sandbox/scripts/setupTypeScript.js b/apps/svelte-sandbox/scripts/setupTypeScript.js index 1eb6b772..ad98f1bb 100644 --- a/apps/svelte-sandbox/scripts/setupTypeScript.js +++ b/apps/svelte-sandbox/scripts/setupTypeScript.js @@ -13,67 +13,75 @@ rm -rf test-template template && git clone sveltejs/template test-template && node scripts/setupTypeScript.js test-template */ -const fs = require("fs") -const path = require("path") -const { argv } = require("process") +const fs = require('fs'); +const path = require('path'); +const { argv } = require('process'); -const projectRoot = argv[2] || path.join(__dirname, "..") +const projectRoot = argv[2] || path.join(__dirname, '..'); // Add deps to pkg.json -const packageJSON = JSON.parse(fs.readFileSync(path.join(projectRoot, "package.json"), "utf8")) +const packageJSON = JSON.parse( + fs.readFileSync(path.join(projectRoot, 'package.json'), 'utf8'), +); packageJSON.devDependencies = Object.assign(packageJSON.devDependencies, { - "svelte-check": "^1.0.0", - "svelte-preprocess": "^4.0.0", - "@rollup/plugin-typescript": "^8.0.0", - "typescript": "^4.0.0", - "tslib": "^2.0.0", - "@tsconfig/svelte": "^1.0.0" -}) + 'svelte-check': '^1.0.0', + 'svelte-preprocess': '^4.0.0', + '@rollup/plugin-typescript': '^8.0.0', + typescript: '^4.0.0', + tslib: '^2.0.0', + '@tsconfig/svelte': '^1.0.0', +}); // Add script for checking packageJSON.scripts = Object.assign(packageJSON.scripts, { - "validate": "svelte-check" -}) + validate: 'svelte-check', +}); // Write the package JSON -fs.writeFileSync(path.join(projectRoot, "package.json"), JSON.stringify(packageJSON, null, " ")) +fs.writeFileSync( + path.join(projectRoot, 'package.json'), + JSON.stringify(packageJSON, null, ' '), +); // mv src/main.js to main.ts - note, we need to edit rollup.config.js for this too -const beforeMainJSPath = path.join(projectRoot, "src", "main.js") -const afterMainTSPath = path.join(projectRoot, "src", "main.ts") -fs.renameSync(beforeMainJSPath, afterMainTSPath) +const beforeMainJSPath = path.join(projectRoot, 'src', 'main.js'); +const afterMainTSPath = path.join(projectRoot, 'src', 'main.ts'); +fs.renameSync(beforeMainJSPath, afterMainTSPath); // Switch the app.svelte file to use TS -const appSveltePath = path.join(projectRoot, "src", "App.svelte") -let appFile = fs.readFileSync(appSveltePath, "utf8") -appFile = appFile.replace("