UNPKG

2.7 kBJavaScriptView Raw
1"use strict";
2
3var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
4 return new (P || (P = Promise))(function (resolve, reject) {
5 function fulfilled(value) {
6 try {
7 step(generator.next(value));
8 } catch (e) {
9 reject(e);
10 }
11 }
12 function rejected(value) {
13 try {
14 step(generator["throw"](value));
15 } catch (e) {
16 reject(e);
17 }
18 }
19 function step(result) {
20 result.done ? resolve(result.value) : new P(function (resolve) {
21 resolve(result.value);
22 }).then(fulfilled, rejected);
23 }
24 step((generator = generator.apply(thisArg, _arguments || [])).next());
25 });
26};
27Object.defineProperty(exports, "__esModule", { value: true });
28const fs_extra_1 = require("fs-extra");
29const path_1 = require("path");
30const utilities_1 = require("../utilities");
31const openInEditor = require('open-in-editor');
32function projectSourceDirectories(workspace) {
33 return utilities_1.flatten([utilities_1.ifElse(workspace.project.isNode, ['client', 'server']), path_1.relative(workspace.paths.root, workspace.paths.app)]);
34}
35exports.projectSourceDirectories = projectSourceDirectories;
36function projectSourceDirectoryGlobPattern(workspace) {
37 const dirs = projectSourceDirectories(workspace);
38 return dirs.length > 1 ? `{${dirs.join(',')}}` : dirs[0];
39}
40exports.projectSourceDirectoryGlobPattern = projectSourceDirectoryGlobPattern;
41function graphQLSchemaPath(workspace, idl = false) {
42 return path_1.join(workspace.paths.build, `schema.${idl ? 'graphql' : 'json'}`);
43}
44exports.graphQLSchemaPath = graphQLSchemaPath;
45function makePrivateDirectory({ paths }) {
46 return __awaiter(this, void 0, void 0, function* () {
47 yield fs_extra_1.mkdirp(paths.private);
48 yield fs_extra_1.writeFile(path_1.join(paths.private, '.gitignore'), '*');
49 });
50}
51exports.makePrivateDirectory = makePrivateDirectory;
52function makeGitIgnoredDirectory(path) {
53 return __awaiter(this, void 0, void 0, function* () {
54 yield fs_extra_1.mkdirp(path);
55 yield fs_extra_1.writeFile(path_1.join(path, '.gitignore'), '*');
56 });
57}
58exports.makeGitIgnoredDirectory = makeGitIgnoredDirectory;
59function openFile(file, { line = 0, column = 0 } = {}) {
60 return __awaiter(this, void 0, void 0, function* () {
61 const editor = openInEditor.configure({
62 pattern: '-r -g',
63 line,
64 column
65 });
66 if (editor == null) {
67 return;
68 }
69 yield editor.open(file);
70 });
71}
72exports.openFile = openFile;
\No newline at end of file