source: trip-planner-front/node_modules/@angular-devkit/schematics/tasks/repo-init/executor.js

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 3.6 KB
Line 
1"use strict";
2/**
3 * @license
4 * Copyright Google LLC All Rights Reserved.
5 *
6 * Use of this source code is governed by an MIT-style license that can be
7 * found in the LICENSE file at https://angular.io/license
8 */
9var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10 if (k2 === undefined) k2 = k;
11 Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
12}) : (function(o, m, k, k2) {
13 if (k2 === undefined) k2 = k;
14 o[k2] = m[k];
15}));
16var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17 Object.defineProperty(o, "default", { enumerable: true, value: v });
18}) : function(o, v) {
19 o["default"] = v;
20});
21var __importStar = (this && this.__importStar) || function (mod) {
22 if (mod && mod.__esModule) return mod;
23 var result = {};
24 if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25 __setModuleDefault(result, mod);
26 return result;
27};
28Object.defineProperty(exports, "__esModule", { value: true });
29const core_1 = require("@angular-devkit/core");
30const child_process_1 = require("child_process");
31const path = __importStar(require("path"));
32function default_1(factoryOptions = {}) {
33 const rootDirectory = factoryOptions.rootDirectory || process.cwd();
34 return async (options = {}, context) => {
35 const authorName = options.authorName;
36 const authorEmail = options.authorEmail;
37 const execute = (args, ignoreErrorStream) => {
38 const outputStream = 'ignore';
39 const errorStream = ignoreErrorStream ? 'ignore' : process.stderr;
40 const spawnOptions = {
41 stdio: [process.stdin, outputStream, errorStream],
42 shell: true,
43 cwd: path.join(rootDirectory, options.workingDirectory || ''),
44 env: {
45 ...process.env,
46 ...(authorName ? { GIT_AUTHOR_NAME: authorName, GIT_COMMITTER_NAME: authorName } : {}),
47 ...(authorEmail
48 ? { GIT_AUTHOR_EMAIL: authorEmail, GIT_COMMITTER_EMAIL: authorEmail }
49 : {}),
50 },
51 };
52 return new Promise((resolve, reject) => {
53 child_process_1.spawn('git', args, spawnOptions).on('close', (code) => {
54 if (code === 0) {
55 resolve();
56 }
57 else {
58 reject(code);
59 }
60 });
61 });
62 };
63 const hasCommand = await execute(['--version']).then(() => true, () => false);
64 if (!hasCommand) {
65 return;
66 }
67 const insideRepo = await execute(['rev-parse', '--is-inside-work-tree'], true).then(() => true, () => false);
68 if (insideRepo) {
69 context.logger.info(core_1.tags.oneLine `
70 Directory is already under version control.
71 Skipping initialization of git.
72 `);
73 return;
74 }
75 // if git is not found or an error was thrown during the `git`
76 // init process just swallow any errors here
77 // NOTE: This will be removed once task error handling is implemented
78 try {
79 await execute(['init']);
80 await execute(['add', '.']);
81 if (options.commit) {
82 const message = options.message || 'initial commit';
83 await execute(['commit', `-m "${message}"`]);
84 }
85 context.logger.info('Successfully initialized git.');
86 }
87 catch { }
88 };
89}
90exports.default = default_1;
Note: See TracBrowser for help on using the repository browser.