timers#clearInterval TypeScript Examples

The following examples show how to use timers#clearInterval. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: gitClient.ts    From iconGenerator with MIT License 6 votes vote down vote up
/**
   * Clone a repository into a folder
   * @param url url repository
   * @param folder foler
   */
  private async cloneRepo(url: string, folder: string): Promise<Repository> {
    const message = `Cloning repo: '${url}' into '${folder.replace(`${this.rootFolder}`, '')}'`;
    const spinner: ISpinner = this.logger.spinnerLogStart(message, this.logGroupId);
    try {
      const clone = await Clone.clone(url, folder);
      this.logger.spinnerLogStop(spinner, message.replace('Cloning', 'Cloned'), this.logGroupId);

      return clone;
    }
    catch (e) {
      clearInterval(spinner.timer);
      throw e;
    }

  }
Example #2
Source File: gitClient.ts    From iconGenerator with MIT License 6 votes vote down vote up
/**
   * Push the master branch
   * @param remote
   * @param numOfCommits
   */
  private async push(remote: Remote, numOfCommits: number, branch: string = 'master') {
    const options: PushOptions = {
      callbacks: {
        credentials: () => Cred.userpassPlaintextNew(this.pargs.account, this.pargs.token),
      },
    };
    const s = numOfCommits > 1 ? 's' : '';
    const spinner: ISpinner = this.logger.spinnerLogStart(`Pushing commit${s} to: ${remote.url()}`, this.logGroupId);
    // Interrupt the push after one minute
    const timer = setTimeout(() => {
      clearInterval(spinner.timer);
      throw new Error('Timeout on push action');
    }, 60000);

    try {
      // Push master
      const result = await remote.push([`refs/heads/${branch}:refs/heads/${branch}`], options);
      this.logger.spinnerLogStop(spinner, `Commit${s} pushed`, this.logGroupId);
      clearTimeout(timer);
      return result;
    }
    catch (e) {
      clearInterval(spinner.timer);
      throw e;
    }
  }
Example #3
Source File: SchedulerHelper.ts    From mooncord with MIT License 5 votes vote down vote up
public clear() {
        clearInterval(this.highScheduler)
        clearInterval(this.moderateScheduler)
        clearInterval(this.statusScheduler)
        clearInterval(this.loadScheduler)
    }
Example #4
Source File: gitClient.ts    From iconGenerator with MIT License 5 votes vote down vote up
/**
   * Commit a filename to the repository
   * @param repo
   * @param filename
   */
  private async commit(repo: Repository, filename: string): Promise<boolean> {
    const spinner: ISpinner = this.logger.spinnerLogStart(`Creating commit`, this.logGroupId);

    try {
      // Refresh all indexes
      const index = await repo.refreshIndex();

      // git add
      await index.addByPath(filename);
      if (!index.write()) {
        throw new Error('Failed writing repo index');
      }

      const matches = filename.match(/associations|folder_associations/i);
      const name = matches && matches[0];
      if (!name) {
        throw new Error('Can not determine list name');
      }

      const commitMessage = `:robot: Update list of ${name.toLowerCase()}`;
      const time = +(Date.now() / 1000).toFixed(0); // unix UTC
      const author = Signature.create('hayate', '[email protected]', time, 0); // our own bot!!
      const committer = author;
      // Get the commit message
      const oid = await index.writeTree();
      // Get the head ID
      const headId = await Reference.nameToId(repo, 'HEAD');

      // Try to create commit
      await repo.createCommit('HEAD', author, committer, commitMessage, oid, [headId]);

      this.logger.spinnerLogStop(spinner, `Commit created: ${headId.tostrS()}`, this.logGroupId);
      return true;
    }
    catch (e) {
      clearInterval(spinner.timer);
      throw e;
    }
  }