diff --git a/docs/develop.md b/docs/develop.md index 15ceb593..f152f8be 100644 --- a/docs/develop.md +++ b/docs/develop.md @@ -16,6 +16,7 @@ git clone https://github.com//clasp.git cd clasp ``` - Install dependencies: `npm install` +- Link-install this development version of `clasp`: `npm link` ### After Making a Change diff --git a/test/README.md b/test/README.md index b5439927..73a75185 100644 --- a/test/README.md +++ b/test/README.md @@ -14,6 +14,8 @@ ## How to Run Tests +Make sure you have completed the [development setup](/docs/develop.md#setup). + 1. Log in: `clasp login` 1. Rebuild: `npm run build` 1. Set environmental variables: diff --git a/test/constants.ts b/test/constants.ts index 1ba740ef..3134b172 100644 --- a/test/constants.ts +++ b/test/constants.ts @@ -2,6 +2,7 @@ import os from 'os'; import path from 'path'; import {ClaspToken} from '../src/dotfile.js'; +import {ClaspError} from '../src/clasp-error.js'; import {randomString} from './functions.js'; import type {OAuth2ClientOptions} from 'google-auth-library'; @@ -27,15 +28,20 @@ export const TEST_APPSSCRIPT_JSON_WITH_RUN_API = JSON.stringify({ // Travis Env Variables export const IS_PR: boolean = process.env.CI === 'true'; -export const SCRIPT_ID: string = process.env.SCRIPT_ID ?? ''; -export const PROJECT_ID: string = process.env.PROJECT_ID ?? ''; -export const PARENT_ID: string[] = [process.env.PROJECT_ID ?? '']; -const HOME: string = process.env.HOME ?? ''; +if (process.env.SCRIPT_ID === undefined) { + throw new ClaspError('Environment variable SCRIPT_ID is not defined.'); +} +export const SCRIPT_ID: string = process.env.SCRIPT_ID; +if (process.env.PROJECT_ID === undefined) { + throw new ClaspError('Environment variable PROJECT_ID is not defined.'); +} +export const PROJECT_ID: string = process.env.PROJECT_ID; +export const PARENT_ID: string[] = [process.env.PROJECT_ID]; // Paths export const CLASP_PATHS = { clientCredsLocal: 'client_credentials.json', - rcGlobal: path.join(HOME, '.clasprc.json'), + rcGlobal: path.join(os.homedir(), '.clasprc.json'), rcLocal: '.clasprc.json', settingsLocal: '.clasp.json', };