當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript loglevel.debug函數代碼示例

本文整理匯總了TypeScript中loglevel.debug函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript debug函數的具體用法?TypeScript debug怎麽用?TypeScript debug使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了debug函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: queryBrowsers

export function queryBrowsers(
  query: string = project.ws.targets.browsers
): Browser[] {
  debug(`Parse browsers from query: ${query}.`);
  const browsers = browserslist(query)
    .map(browser => {
      let [name, version] = browser.split(' ');
      const hasVersionRange = version.includes('-');
      if (hasVersionRange) {
        version = version.split('-')[1];
      }
      return { name, version };
    })
    .filter(({ name }) =>
      supportedBrowsers.some(({ browserslist }) => browserslist === name)
    )
    .map(({ name, version }) => {
      const browserName = supportedBrowsers.find(
        ({ browserslist }) => browserslist === name
      )!.selenium;
      return {
        browserName,
        version,
        id: `${browserName}-${version}`
      };
    });

  debug(`Parsed browsers: ${browsers.map(({ id }) => id)}.`);
  return browsers;
}
開發者ID:otbe,項目名稱:ws,代碼行數:30,代碼來源:get-browsers.ts

示例2: Server

 const server = new Server(karmaConfig, exitCode => {
   debug(`Karma finished.`);
   if (sauceConnectProcess) {
     debug(`Tries to close Sauce Connect.`);
     sauceConnectProcess.close(() => {
       debug(`Closed Sauce Connect.`);
       resolve(exitCode);
     });
   } else {
     resolve(exitCode);
   }
 });
開發者ID:otbe,項目名稱:ws,代碼行數:12,代碼來源:karma.ts

示例3: importTranslation

function importTranslation(locale: string, feature: string, i18n: I18nConfig) {
  // at this place we know i18n.importUrl config is set, no need for null checks
  const url = urlTemplate.parse(i18n.importUrl!).expand({ locale, feature });
  const outputPath = join(
    process.cwd(),
    i18n.dir,
    feature,
    `${locale}.properties`
  );

  debug(`Import from ${url}.`);

  return new Promise<void>((resolve, reject) => {
    get(url, res => {
      let body = '';
      res.on('data', data => (body = body + data));
      res.on('error', err => console.log(err));
      res.on('end', () => {
        if (IGNORED_CONTENTS.some(content => body === content)) {
          resolve();
        } else {
          outputFileAsync(outputPath, body)
            .then(() => resolve())
            .catch(reject);
        }
      });
    }).on('error', reject);
  });
}
開發者ID:otbe,項目名稱:ws,代碼行數:29,代碼來源:i18n-import.ts

示例4: readTranslation

async function readTranslation(
  cwd: string,
  dir: string,
  locale: string,
  feature: string
): Promise<Translation> {
  const readPath = join(cwd, dir, feature, `${locale}.properties`);

  debug(`Read from ${readPath}.`);

  const translation: Translation = await readFileAsync(readPath, 'utf8')
    .then(parse)
    .catch(err => {
      if (err.code === 'ENOENT') {
        // translations can be "empty"
        return {};
      } else {
        throw err;
      }
    })
    .then(camelCaseKeys)
    .then(data => ({ data, locale }));

  return translation;
}
開發者ID:otbe,項目名稱:ws,代碼行數:25,代碼來源:get-translations.ts

示例5: testAsync

export async function testAsync(options: { grid?: boolean } = {}) {
  debug(`Configure Karma...`);
  const karmaConfig = Object.assign({}, defaultConfig, {
    basePath: process.cwd(),
    files: [
      join(project.ws.distTestsDir, project.ws.i18n ? project.ws.i18n.locales[0] : '', 'index.js')
    ],
    preprocessors: {
      [join(project.ws.distTestsDir, 'index.js')]: [ 'sourcemap' ]
    }
  });

  let sauceConnectProcess;
  if (options.grid) {
    const {
      host,
      port,
      filterForAvailability
    } = project.ws.selenium;
    const browsersQuery = project.ws.browsers;
    const browsers = filterForAvailability ? await getBrowsersFilteredByAvailability() : getBrowsers();

    if (browsers.length === 0) {
      throw `No browsers are available on ${yellow(`${host}:${port}`)} given ${yellow(browsersQuery)}.`;
    }

    const customLaunchers = browsers.reduce(toCustomLaunchersObject, {});
    Object.assign(karmaConfig, {
      hostname: getIpAddress(),
      customLaunchers,
      browsers: Object.keys(customLaunchers)
    });

    if (isSauceLabsHost(host)) {
      const {
        user: username,
        password: accessKey
      } = project.ws.selenium;
      sauceConnectProcess = await launchSauceConnect({ username, accessKey });
    }
  }

  return new Promise((resolve, reject) => {
    const server = new Server(karmaConfig, (exitCode) => {
      debug(`Karma finished.`);
      if (sauceConnectProcess) {
        debug(`Tries to close Sauce Connect.`);
        sauceConnectProcess.close(() => {
          debug(`Closed Sauce Connect.`);
          resolve(exitCode);
        });
      } else {
        resolve(exitCode);
      }
    });

    debug(`Start Karma.`);
    server.start();
  });
}
開發者ID:Mercateo,項目名稱:typedocs,代碼行數:60,代碼來源:karma.ts

示例6: getBrowsersFilteredByAvailability

export async function getBrowsersFilteredByAvailability(browsers: string = project.ws.browsers): Promise<Browser[]> {
  const availableBrowsers = await getAvailableBrowsers();
  const availableBrowsersData = availableBrowsers
    .filter(({ browserName }) => supportedBrowsers.some(({ selenium }) => selenium === browserName))
    .reduce((data, browser) => {
      const name = supportedBrowsers.find(({ selenium }) => selenium === browser.browserName).browserslist;
      if (data[name]) {
        data[name].released.unshift(browser.version);
        data[name].versions.unshift(browser.version);
      } else {
        data[name] = {
          name,
          released: [ browser.version ],
          versions: [ browser.version ]
        };
      }
      return data;
    }, {});

  // override `browserslist.data`
  browserslist.data = availableBrowsersData;
  const browsersFilteredByAvailability = getBrowsers(browsers);
  // restore`browserslist.data`
  browserslist.data = originalData;

  debug(`Filtered available browsers: ${browsersFilteredByAvailability.map(({ id }) => id)}.`);
  return browsersFilteredByAvailability;
}
開發者ID:Mercateo,項目名稱:typedocs,代碼行數:28,代碼來源:selenium-grid.ts

示例7: reject

 grid.available({ host, port }, (err, nodes) => {
   if (err) {
     reject(err);
   } else {
     debug(`Found ${nodes.length} nodes.`);
     resolve(nodes);
   }
 });
開發者ID:otbe,項目名稱:ws,代碼行數:8,代碼來源:get-browsers.ts

示例8: sauceConnectLauncher

 sauceConnectLauncher(options, (err, sauceConnectProcess) => {
   if (err) {
     reject(err);
   } else {
     debug('Launched Sauce Connect.');
     resolve(sauceConnectProcess);
   }
 });
開發者ID:otbe,項目名稱:ws,代碼行數:8,代碼來源:sauce-connect.ts

示例9: getAllAvailableBrowsers

async function getAllAvailableBrowsers(): Promise<Browser[]> {
  let browsersWithoutId: { version: string; browserName: string }[];
  if (isSauceLabsHost(project.ws.selenium!.host)) {
    debug(`Get available browsers on Sauce Labs.`);
    const platforms: any = await new Promise((resolve, reject) => {
      get(SAUCE_LABS_PLATFORMS, res => {
        let body = '';
        res.on('data', data => (body = body + data));
        res.on('end', () => resolve(JSON.parse(body)));
      }).on('error', reject);
    });
    browsersWithoutId = platforms
      .map(({ api_name, short_version }: any) => ({
        // treat 'iphone' like 'ipad' (same browser)
        browserName: api_name === 'iphone' ? 'ipad' : api_name,
        version: short_version
      }))
      // sauce labs supports beta/dev versions, but we can't map them back to browserslist
      .filter(({ version }: any) => version !== 'dev' && version !== 'beta');
  } else {
    debug(`Get available browsers on Selenium Grid.`);
    // convert status like https://github.com/davglass/selenium-grid-status#usage
    // to a list of unique browsers containing just the `browserName`, `version` and `id`
    const nodes = await getNodes();
    browsersWithoutId = flatten(nodes.map(node => node.browser)).map(
      ({ browserName, version }) => ({
        // treat 'iphone' like 'ipad' (same browser)
        browserName: browserName === 'iphone' ? 'ipad' : browserName,
        version
      })
    );
  }
  const browsersWithId: Browser[] = browsersWithoutId.map(
    ({ version, browserName }) => ({
      browserName,
      version,
      id: `${browserName}-${version}`
    })
  );
  const browsers = uniqBy(browsersWithId, 'id').sort(sortByVersion);

  debug(`Available browsers: ${browsers.map(({ id }) => id)}.`);
  return browsers;
}
開發者ID:otbe,項目名稱:ws,代碼行數:44,代碼來源:get-browsers.ts

示例10: load

 public load(): void {
   let filePath: string = this.filePath;
   log.debug(`Loadig ${filePath}.`);
   let result: IConfig;
   if (fs.existsSync(filePath)) {
     result = JSON.parse(fs.readFileSync(filePath).toString());
   } else {
     result = {};
   }
   if (!result.recentSaveBaseDirs) result.recentSaveBaseDirs = [];
   this.$hub.config = result;
 }
開發者ID:nashika,項目名稱:spreadsheet-code-generator,代碼行數:12,代碼來源:config.service.ts


注:本文中的loglevel.debug函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。