How to use distDir method in Best

Best JavaScript code snippet using best

tw.mjs

Source:tw.mjs Github

copy

Full Screen

1import path from 'path';2import fs from 'fs-extra';3import tw from 'tiddlywiki';4import UglifyJS from 'uglify-js';5import { minify as htmlMinify } from 'html-minifier-terser';6import { tryCopy, htmlMinifierOptions, shell } from './utils.mjs';7/** 项目路径 */8const repoFolder = process.cwd();9const wikiFolder = path.join(repoFolder, 'wiki');10const tiddlersFolder = path.join(wikiFolder, 'tiddlers');11const publicFolder = path.join(repoFolder, 'public');12const runTiddlyWiki = (argv) => {13 shell(`npx tiddlywiki ${argv.join(' ')}`);14};15/**16 * 构建在线HTML版本:核心JS和资源文件不包括在HTML中, 下载后不能使用17 * @param {string} distDir 目标路径,空或者不填则默认为'dist'18 * @param {string} htmlName HTML名称,空或者不填则默认为'index.html'19 * @param {boolean} minify 是否最小化JS和HTML,默认为true20 * @param {string} excludeFilter 要排除的tiddler的过滤表达式,默认为'-[is[draft]]'21 */22export const buildOnlineHTML = async (distDir, htmlName, minify, excludeFilter) => {23 distDir = path.resolve(typeof distDir !== 'string' || distDir.length === 0 ? 'dist' : distDir);24 if (typeof htmlName !== 'string' || htmlName.length === 0) htmlName = 'index.html';25 minify = minify !== false;26 if (typeof excludeFilter !== 'string') excludeFilter = '-[is[draft]]';27 const $tw = tw.TiddlyWiki();28 $tw.boot.argv = ['.'];29 $tw.boot.boot();30 // 静态资源拷贝31 fs.mkdirsSync(distDir);32 fs.copySync(publicFolder, distDir, { overwrite: true });33 tryCopy(path.join(tiddlersFolder, 'favicon.ico'), path.join(distDir, 'favicon.ico'));34 tryCopy(path.join(tiddlersFolder, 'TiddlyWikiIconWhite.png'), path.join(distDir, 'TiddlyWikiIconWhite.png'));35 tryCopy(path.join(tiddlersFolder, 'TiddlyWikiIconBlack.png'), path.join(distDir, 'TiddlyWikiIconBlack.png'));36 // 构建HTML37 // 备份 因为下面有改变tiddler的field的操作(媒体文件全部转为canonical)38 const backupFolder = path.join(wikiFolder, 'tmp_tiddlers_backup');39 fs.mkdirsSync(backupFolder);40 fs.copySync(tiddlersFolder, backupFolder, { overwrite: true });41 runTiddlyWiki([42 wikiFolder /* 指定wiki路径 */,43 ...['--output', distDir] /* 指定输出路径 */,44 ...['--deletetiddlers', "'[[$:/UpgradeLibrary]] [[$:/UpgradeLibrary/List]]'"] /* 删掉一些没必要导出而且占用很大的条目 */,45 ...[46 '--setfield',47 "'[is[image]] [is[binary]] [type[application/msword]] [type[image/svg+xml]]'",48 '_canonical_uri',49 '$:/core/templates/canonical-uri-external-image',50 'text/plain',51 ] /* 媒体条目转外链 */,52 ...[53 '--setfield',54 "'[is[image]] [is[binary]] [type[application/msword]] [type[image/svg+xml]]'",55 'text',56 "''",57 'text/plain',58 ] /* 媒体条目内容清空:注意这一步也会把所有媒体文件的内容变成空的 */,59 ...[60 '--rendertiddler',61 '$:/core/save/offline-external-js',62 'index-raw.html',63 'text/plain',64 "''",65 'publishFilter',66 `'${excludeFilter}'`,67 ] /* 导出无核心的HTML文件 */,68 ...['--rendertiddler', '$:/core/templates/tiddlywiki5.js', 'tiddlywikicore.js', 'text/plain'] /* 导出核心 */,69 ]);70 // 将所有的二进制文件(媒体文件, 参考$tw.utils.registerFileType)导出71 const binaryExtensionMap = {};72 Object.keys($tw.config.fileExtensionInfo).forEach((ext) => {73 const _info = $tw.config.fileExtensionInfo[ext];74 const info = $tw.config.contentTypeInfo[_info.type];75 if (info && info.encoding === 'base64') binaryExtensionMap[ext.toLowerCase()] = true;76 });77 const distMediaFolder = path.join(distDir, 'images');78 fs.mkdirsSync(distMediaFolder);79 fs.copySync(backupFolder, distMediaFolder, {80 overwrite: true,81 filter: (src, _dest) => {82 if (src === backupFolder) return true;83 return binaryExtensionMap[path.extname(src).toLowerCase()] === true;84 },85 });86 // 恢复被清空内容的媒体文件87 fs.copySync(backupFolder, tiddlersFolder, { overwrite: true });88 fs.rmSync(backupFolder, { recursive: true, force: true });89 // 最小化:核心JS和HTML90 const rawCoreJsPath = path.join(distDir, 'tiddlywikicore.js');91 const rawHTMLPath = path.join(distDir, 'index-raw.html');92 if (minify) {93 // 核心94 let result = UglifyJS.minify(fs.readFileSync(rawCoreJsPath).toString('utf-8'), {95 warnings: false,96 v8: true,97 ie: true,98 webkit: true,99 });100 fs.writeFileSync(rawCoreJsPath, result.code);101 // 网页102 result = await htmlMinify(fs.readFileSync(rawHTMLPath).toString('utf-8'), htmlMinifierOptions);103 fs.writeFileSync(rawHTMLPath, result);104 }105 fs.moveSync(rawCoreJsPath, path.join(distDir, `tiddlywikicore-${$tw.packageInfo.version}.js`), { overwrite: true });106 fs.moveSync(rawHTMLPath, path.join(distDir, htmlName), { overwrite: true });107};108/**109 * 构建离线HTML版本:核心JS和资源文件包括在HTML中, 下载后可以使用(就是单文件版本的wiki)110 * @param {string} distDir 目标路径,空或者不填则默认为'dist'111 * @param {string} htmlName HTML名称,空或者不填则默认为'index.html'112 * @param {boolean} minify 是否最小化JS和HTML,默认为true113 * @param {string} excludeFilter 要排除的tiddler的过滤表达式,默认为'-[is[draft]]'114 */115export const buildOfflineHTML = async (distDir, htmlName, minify, excludeFilter) => {116 distDir = path.resolve(typeof distDir !== 'string' || distDir.length === 0 ? 'dist' : distDir);117 if (typeof htmlName !== 'string' || htmlName.length === 0) htmlName = 'index.html';118 minify = minify !== false;119 if (typeof excludeFilter !== 'string') excludeFilter = '-[is[draft]]';120 // 构建HTML121 fs.mkdirsSync(distDir);122 runTiddlyWiki([123 wikiFolder /* 指定wiki路径 */,124 ...['--output', distDir] /* 指定输出路径 */,125 ...['--deletetiddlers', "'[[$:/UpgradeLibrary]] [[$:/UpgradeLibrary/List]]'"] /* 删掉一些没必要导出而且占用很大的条目 */,126 ...[127 '--rendertiddler',128 '$:/plugins/tiddlywiki/tiddlyweb/save/offline',129 'index-raw.html',130 'text/plain',131 "''",132 'publishFilter',133 `'${excludeFilter}'`,134 ] /* 将wiki导出为HTML */,135 ]);136 // 最小化:HTML137 const rawHTMLPath = path.join(distDir, 'index-raw.html');138 if (minify) {139 const result = await htmlMinify(fs.readFileSync(rawHTMLPath).toString('utf-8'), htmlMinifierOptions);140 fs.writeFileSync(rawHTMLPath, result);141 }142 fs.moveSync(rawHTMLPath, path.join(distDir, htmlName), { overwrite: true });143};144/**145 * 构建插件源146 * @param {string} pluginFilter 要发布插件的过滤器,默认为 '[prefix[$:/plugins/]!prefix[$:/plugins/tiddlywiki/]!prefix[$:/languages/]!prefix[$:/themes/tiddlywiki/]!tag[$:/tags/PluginLibrary]]'147 * @param {string} distDir 目标路径,空或者不填则默认为'dist/library'148 * @param {boolean} minify 是否最小化HTML,默认为true149 */150export const buildLibrary = async (pluginFilter, distDir, minify) => {151 if (typeof pluginFilter !== 'string' || pluginFilter.length === 0)152 pluginFilter = '[prefix[$:/plugins/]!prefix[$:/plugins/tiddlywiki/]!prefix[$:/languages/]!prefix[$:/themes/tiddlywiki/]!tag[$:/tags/PluginLibrary]]';153 distDir = path.resolve(typeof distDir !== 'string' || distDir.length === 0 ? 'dist/library' : distDir);154 minify = minify !== false;155 // 构建HTML156 fs.mkdirsSync(distDir);157 runTiddlyWiki([158 wikiFolder /* 指定wiki路径 */,159 ...['--output', distDir] /* 指定输出路径 */,160 ...['--makelibrary', '$:/UpgradeLibrary'] /* 收集所有已安装插件 */,161 ...['--savelibrarytiddlers', '$:/UpgradeLibrary', `'${pluginFilter}'`, 'recipes/library/tiddlers/', '$:/UpgradeLibrary/List'] /* 导出指定的插件 */,162 ...['--savetiddler', '$:/UpgradeLibrary/List', 'recipes/library/tiddlers.json'] /* 生成插件集合JSON文件 */,163 ...['--rendertiddler', '$:/plugins/tiddlywiki/pluginlibrary/library.template.html', 'index-raw.html', 'text/plain'] /* 生成插件库HTML文件 */,164 ...['--deletetiddlers', "'[[$:/UpgradeLibrary]] [[$:/UpgradeLibrary/List]]'"] /* 删掉中间内容 */,165 ]);166 // 最小化:HTML167 const rawHTMLPath = path.join(distDir, 'index-raw.html');168 if (minify) {169 const result = await htmlMinify(fs.readFileSync(rawHTMLPath).toString('utf-8'), htmlMinifierOptions);170 fs.writeFileSync(rawHTMLPath, result);171 }172 fs.moveSync(rawHTMLPath, path.join(distDir, 'index.html'), { overwrite: true });...

Full Screen

Full Screen

build.js

Source:build.js Github

copy

Full Screen

1const path = require('path');2const {3 execSync4} = require('child_process');5/** 项目路径 */6const repoFolder = path.join(path.dirname(__filename), '..');7/** 获得TW版本号 */8const getVersion = '$(npx tiddlywiki . --version | grep -Eo \'^[0-9]+\.[0-9]+\.[0-9]+.*$\' | head -n 1)';9/** 设置环境变量,TW会同时在自己的源码路径以及环境变量定义的路径中寻找插件、主题和语言10 * 如果不这样写,plugins、themes、languages和editions里的内容就无法被加载11 */12process.env.TIDDLYWIKI_PLUGIN_PATH = `${repoFolder}/plugins`;13process.env.TIDDLYWIKI_THEME_PATH = `${repoFolder}/themes`;14process.env.TIDDLYWIKI_LANGUAGE_PATH = `${repoFolder}/languages`;15process.env.TIDDLYWIKI_EDITION_PATH = `${repoFolder}/editions`;16/**17 * 执行命令行指令,并打印该指令的结果18 * @param {string} command 要执行的命令19 * @param {object} options execSync的参数20 */21function shell(command, options) {22 if (options !== undefined) options = {};23 console.log(String(execSync(command, {24 cwd: repoFolder,25 ...options,26 })));27}28/**29 * 执行命令行指令,并打印该指令的结果,同时忽略任何错误30 * @param {string} command 要执行的命令31 * @param {object} options execSync的参数32 */33function shellI(command, options) {34 try {35 shell(command, options);36 } catch (error) {37 console.error(`[Shell Command Error] ${error}`)38 }39}40/**41 * 构建在线HTML版本:核心JS和资源文件不包括在HTML中, 下载后不能使用42 * @param {string} distDir 目标路径,空或者不填则默认为'dist'43 * @param {string} htmlName HTML名称,空或者不填则默认为'index.html'44 * @param {boolean} minify 是否最小化JS和HTML,默认为true45 * @param {string} excludeFilter 要排除的tiddler的过滤表达式,默认为'-[is[draft]]'46 */47function buildOnlineHTML(distDir, htmlName, minify, excludeFilter) {48 if (typeof distDir !== 'string' || distDir.length === 0) distDir = 'dist';49 if (typeof htmlName !== 'string' || htmlName.length === 0) htmlName = 'index.html';50 if (typeof minify !== 'boolean') minify = true;51 if (typeof excludeFilter !== 'string') excludeFilter = '-[is[draft]]';52 // 清空生成目标53 shell(`rm -rf ${distDir}`);54 // 静态资源拷贝55 shellI(`cp -r public/ ${distDir} &> /dev/null`);56 shellI(`cp tiddlers/favicon.ico ${distDir}/favicon.ico &> /dev/null`);57 shellI(`cp tiddlers/TiddlyWikiIconWhite.png ${distDir}/TiddlyWikiIconWhite.png &> /dev/null`);58 shellI(`cp tiddlers/TiddlyWikiIconBlack.png ${distDir}/TiddlyWikiIconBlack.png &> /dev/null`);59 // 部署 vercel60 shellI(`cp vercel.json ${distDir}/vercel.json &> /dev/null`);61 // 构建HTML62 shell('cp -r tiddlers/ tmp_tiddlers_backup &> /dev/null'); // 备份 因为下面有改变tiddler的field的操作(媒体文件全部转为canonical)63 shell(`npx tiddlywiki . --output ${distDir}` +64 ' --deletetiddlers \'[[$:/UpgradeLibrary]] [[$:/UpgradeLibrary/List]]\'' +65 ' --setfield \'[is[image]] [is[binary]] [type[application/msword]] [type[image/svg+xml]]\' _canonical_uri $:/core/templates/canonical-uri-external-image text/plain' +66 ' --setfield \'[is[image]] [is[binary]] [type[application/msword]] [type[image/svg+xml]]\' text "" text/plain' + /* 注意这一步也会把所有媒体文件的内容变成空的 */67 ` --rendertiddler $:/core/save/offline-external-js index-raw.html text/plain "" publishFilter "${excludeFilter}"` +68 ' --rendertiddler $:/core/templates/tiddlywiki5.js tiddlywikicore.js text/plain'69 );70 shell('cp -r tmp_tiddlers_backup/* tiddlers &> /dev/null'); // 恢复被清空内容的媒体文件71 // 删除非二进制文件,后缀类型定义在 boot.js ($tw.utils.registerFileType(...))72 shellI('cd tiddlers && rm *.meta *.tid *.multids *.tiddler *.recipe *.txt *.css *.html *.htm *.hta *.js *.json *.md *.bib &> /dev/null');73 shellI(`mkdir ${distDir}/images &> /dev/null`);74 shell(`mv tiddlers/*.* ${distDir}/images &> /dev/null`); // 非二进制文件也就是资源文件的拷贝75 shell('rm -rf tiddlers && mv tmp_tiddlers_backup tiddlers &> /dev/null'); // 还原76 // 最小化:核心JS和HTML77 if (minify) {78 shellI(`npx uglifyjs ${distDir}/tiddlywikicore.js -c -m --v8 --webkit --ie --output '${distDir}/tiddlywikicore-'${getVersion}'.js' && rm ${distDir}/tiddlywikicore.js`);79 shellI(`npx html-minifier-terser -c scripts/html-minifier-terser.config.json -o ${distDir}/${htmlName} ${distDir}/index-raw.html && rm ${distDir}/index-raw.html`);80 } else {81 shellI(`mv ${distDir}/tiddlywikicore.js '${distDir}/tiddlywikicore-'${getVersion}'.js'`);82 shellI(`mv ${distDir}/index-raw.html ${distDir}/${htmlName}`);83 }84}85/**86 * 构建离线HTML版本:核心JS和资源文件包括在HTML中, 下载后可以使用(就是单文件版本的wiki)87 * @param {string} distDir 目标路径,空或者不填则默认为'dist'88 * @param {string} htmlName HTML名称,空或者不填则默认为'index.html'89 * @param {boolean} minify 是否最小化JS和HTML,默认为true90 * @param {string} excludeFilter 要排除的tiddler的过滤表达式,默认为'-[is[draft]]'91 */92function buildOfflineHTML(distDir, htmlName, minify, excludeFilter) {93 if (typeof distDir !== 'string' || distDir.length === 0) distDir = 'dist';94 if (typeof htmlName !== 'string' || htmlName.length === 0) htmlName = 'index.html';95 if (typeof minify !== 'boolean') minify = true;96 if (typeof excludeFilter !== 'string') excludeFilter = '-[is[draft]]';97 // 构建HTML98 shell(`npx tiddlywiki . --output ${distDir}` +99 ' --deletetiddlers \'[[$:/UpgradeLibrary]] [[$:/UpgradeLibrary/List]]\'' +100 ` --rendertiddler $:/plugins/tiddlywiki/tiddlyweb/save/offline index-raw.html text/plain "" publishFilter "${excludeFilter}"`101 );102 // 最小化:HTML103 if (minify) {104 shellI(`npx html-minifier-terser -c scripts/html-minifier-terser.config.json -o ${distDir}/${htmlName} ${distDir}/index-raw.html && rm ${distDir}/index-raw.html`);105 } else {106 shellI(`mv ${distDir}/index-raw.html ${distDir}/${htmlName}`);107 }108}109/**110 * 构建插件源111 * @param {string} pluginFilter 要发布插件的过滤器,默认为 '[prefix[$:/plugins/]!prefix[$:/plugins/tiddlywiki/]!prefix[$:/languages/]!prefix[$:/themes/tiddlywiki/]!tag[$:/tags/PluginLibrary]]'112 * @param {string} distDir 目标路径,空或者不填则默认为'dist/library'113 * @param {boolean} minify 是否最小化HTML,默认为true114 */115function buildLibrary(pluginFilter, distDir, minify) {116 if (typeof pluginFilter !== 'string' || pluginFilter.length === 0) pluginFilter = '[prefix[$:/plugins/]!prefix[$:/plugins/tiddlywiki/]!prefix[$:/languages/]!prefix[$:/themes/tiddlywiki/]!tag[$:/tags/PluginLibrary]]';117 if (typeof distDir !== 'string' || distDir.length === 0) distDir = 'dist/library';118 if (typeof minify !== 'boolean') minify = true;119 shell(`npx tiddlywiki . --output ${distDir}` +120 ' --makelibrary $:/UpgradeLibrary' +121 ` --savelibrarytiddlers $:/UpgradeLibrary ${pluginFilter} recipes/library/tiddlers/ $:/UpgradeLibrary/List` +122 ' --savetiddler $:/UpgradeLibrary/List recipes/library/tiddlers.json' +123 ' --rendertiddler $:/plugins/tiddlywiki/pluginlibrary/library.template.html index-raw.html text/plain' +124 ' --deletetiddlers \'[[$:/UpgradeLibrary]] [[$:/UpgradeLibrary/List]]\''125 );126 // 最小化:HTML127 if (minify) {128 shellI(`npx html-minifier-terser -c scripts/html-minifier-terser.config.json -o ${distDir}/index.html ${distDir}/index-raw.html && rm ${distDir}/index-raw.html`);129 } else {130 shellI(`mv ${distDir}/index-raw.html ${distDir}/${htmlName}`);131 }132}133module.exports = {134 buildOnlineHTML: buildOnlineHTML,135 buildOfflineHTML: buildOfflineHTML,136 buildLibrary: buildLibrary,...

Full Screen

Full Screen

gruntFile.js

Source:gruntFile.js Github

copy

Full Screen

1module.exports = function (grunt) {2 grunt.loadNpmTasks('grunt-contrib-concat');3 grunt.loadNpmTasks('grunt-contrib-jshint');4 grunt.loadNpmTasks('grunt-contrib-uglify');5 grunt.loadNpmTasks('grunt-contrib-clean');6 grunt.loadNpmTasks('grunt-contrib-copy');7 grunt.loadNpmTasks('grunt-contrib-watch');8 grunt.loadNpmTasks('grunt-recess');9 grunt.loadNpmTasks('grunt-karma');10 grunt.loadNpmTasks('grunt-html2js');11 // Default task.12 grunt.registerTask('default', ['jshint','build','karma:unit']);13 grunt.registerTask('build', ['clean','html2js','concat','copy:assets','recess:build']);14 grunt.registerTask('release', ['clean','html2js','uglify','jshint','karma:unit','concat:index', 'recess:min','copy:assets']);15 grunt.registerTask('test-watch', ['karma:watch']);16 // Print a timestamp (useful for when watching)17 grunt.registerTask('timestamp', function() {18 grunt.log.subhead(Date());19 });20 var karmaConfig = function(configFile, customOptions) {21 var options = { configFile: configFile, keepalive: true };22 var travisOptions = process.env.TRAVIS && { browsers: ['Chrome'], reporters: 'dots' };23 return grunt.util._.extend(options, customOptions, travisOptions);24 };25 // Project configuration.26 grunt.initConfig({27 distdir: 'dist',28 pkg: grunt.file.readJSON('package.json'),29 banner:30 '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' +31 '<%= pkg.homepage ? " * " + pkg.homepage + "\\n" : "" %>' +32 ' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author %>;\n' +33 ' * Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %>\n */\n',34 src: {35 js: ['src/**/*.js', '<%= distdir %>/templates/**/*.js'],36 specs: ['test/**/*.spec.js'],37 scenarios: ['test/**/*.scenario.js'],38 html: ['src/index.html'],39 ico: ['src/assets/favicon.ico'],40 tpl: {41 app: ['src/app/**/*.tpl.html'],42 common: ['src/common/**/*.tpl.html']43 },44 less: ['src/less/stylesheet.less'], // recess:build doesn't accept ** in its file patterns45 lessWatch: ['src/less/**/*.less']46 },47 clean: ['<%= distdir %>/*'],48 copy: {49 assets: {50 files: [{ dest: '<%= distdir %>/assets/', src : '**', expand: true, cwd: 'src/assets/' }]51 },52 mozilla: {53 files: [{ dest: '<%= distdir %>', src : '**', expand: true, cwd: 'vendor/mozilla/' }]54 }55 },56 karma: {57 unit: { options: karmaConfig('test/config/unit.js') },58 watch: { options: karmaConfig('test/config/unit.js', { singleRun:false, autoWatch: true}) }59 },60 html2js: {61 app: {62 options: {63 base: 'src/app'64 },65 src: ['<%= src.tpl.app %>'],66 dest: '<%= distdir %>/templates/app.js',67 module: 'templates.app'68 },69 common: {70 options: {71 base: 'src/common'72 },73 src: ['<%= src.tpl.common %>'],74 dest: '<%= distdir %>/templates/common.js',75 module: 'templates.common'76 }77 },78 concat:{79 dist:{80 options: {81 banner: "<%= banner %>"82 },83 src:['<%= src.js %>'],84 dest:'<%= distdir %>/<%= pkg.name %>.js'85 },86 index: {87 src: ['src/index.html'],88 dest: '<%= distdir %>/index.html',89 options: {90 process: true91 }92 },93 favicon: {94 src: ['src/assets/favicon.ico'],95 dest: '<%= distdir %>/favicon.ico'96 },97 angular: {98 src:['vendor/angular/angular.min.js'],99 dest: '<%= distdir %>/angular.js'100 },101 angularresource: {102 src:['vendor/angular/angular-resource.js'],103 dest: '<%= distdir %>/angular-resource.js'104 },105 bootstrap: {106 src:['vendor/bootstrap/*.js'],107 dest: '<%= distdir %>/bootstrap.js'108 },109 pdfdebug: {110 src:['vendor/mozilla/debugger.js'],111 dest: '<%= distdir %>/debugger.js'112 },113 pdfl10n: {114 src:['vendor/mozilla/l10n.js'],115 dest: '<%= distdir %>/l10n.js'116 },117 viewer: {118 src:['vendor/mozilla/viewer.js'],119 dest: '<%= distdir %>/viewer.js'120 },121 pdf: {122 src:['vendor/mozilla/pdf.js'],123 dest: '<%= distdir %>/pdf.js'124 }125 },126 uglify: {127 dist:{128 options: {129 banner: "<%= banner %>"130 },131 src:['<%= src.js %>'],132 dest:'<%= distdir %>/<%= pkg.name %>.js'133 },134 angular: {135 src:['<%= concat.angular.src %>'],136 dest: '<%= distdir %>/angular.js'137 },138 bootstrap: {139 src:['vendor/bootstrap/bootstrap/*.js'],140 dest: '<%= distdir %>/bootstrap.js'141 },142 jquery: {143 src:['vendor/jquery/*.js'],144 dest: '<%= distdir %>/jquery.js'145 }146 },147 recess: {148 build: {149 files: {150 '<%= distdir %>/<%= pkg.name %>.css':151 ['<%= src.less %>'] },152 options: {153 compile: true154 }155 },156 min: {157 files: {158 '<%= distdir %>/<%= pkg.name %>.css': ['<%= src.less %>']159 },160 options: {161 compress: true162 }163 }164 },165 watch:{166 all: {167 files:['<%= src.js %>', '<%= src.specs %>', '<%= src.lessWatch %>', '<%= src.tpl.app %>', '<%= src.tpl.common %>', '<%= src.html %>'],168 tasks:['default','timestamp']169 },170 build: {171 files:['<%= src.js %>', '<%= src.specs %>', '<%= src.lessWatch %>', '<%= src.tpl.app %>', '<%= src.tpl.common %>', '<%= src.html %>'],172 tasks:['build','timestamp']173 }174 },175 jshint:{176 files:['gruntFile.js', '<%= src.js %>', '<%= src.specs %>', '<%= src.scenarios %>'],177 options:{178 curly:true,179 eqeqeq:true,180 immed:true,181 latedef:true,182 newcap:true,183 noarg:true,184 sub:true,185 boss:true,186 eqnull:true,187 globals:{}188 }189 }190 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestFit = require('bestfit');2var bf = new BestFit();3var dist = bf.distDir(10, 10, 5, 5);4console.log(dist);5var BestFit = require('bestfit');6var bf = new BestFit();7var dist = bf.distDir(10, 10, 5, 5);8console.log(dist);9var BestFit = require('bestfit');10var bf = new BestFit();11var dist = bf.distDir(10, 10, 5, 5);12console.log(dist);13var BestFit = require('bestfit');14var bf = new BestFit();15var dist = bf.distDir(10, 10, 5, 5);16console.log(dist);17var BestFit = require('bestfit');18var bf = new BestFit();19var dist = bf.distDir(10, 10, 5, 5);20console.log(dist);21var BestFit = require('bestfit');22var bf = new BestFit();23var dist = bf.distDir(10, 10, 5, 5);24console.log(dist);25var BestFit = require('bestfit');26var bf = new BestFit();27var dist = bf.distDir(10, 10, 5, 5);28console.log(dist);29var BestFit = require('bestfit');30var bf = new BestFit();31var dist = bf.distDir(10, 10, 5, 5);32console.log(dist);33var BestFit = require('bestfit');34var bf = new BestFit();35var dist = bf.distDir(10, 10, 5, 5);36console.log(dist);

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestPath = Java.type("BestPath");2var Graph = Java.type("Graph");3var Node = Java.type("Node");4var Edge = Java.type("Edge");5var g = new Graph();6var n1 = new Node("1");7var n2 = new Node("2");8var n3 = new Node("3");9var n4 = new Node("4");10var n5 = new Node("5");11var n6 = new Node("6");12var n7 = new Node("7");13var n8 = new Node("8");14var n9 = new Node("9");15g.addNode(n1);16g.addNode(n2);17g.addNode(n3);18g.addNode(n4);19g.addNode(n5);20g.addNode(n6);21g.addNode(n7);22g.addNode(n8);23g.addNode(n9);24var e1 = new Edge(n1, n2, 4);25var e2 = new Edge(n1, n8, 8);26var e3 = new Edge(n2, n3, 8);27var e4 = new Edge(n2, n8, 11);28var e5 = new Edge(n3, n4, 7);29var e6 = new Edge(n3, n9, 2);30var e7 = new Edge(n3, n6, 4);31var e8 = new Edge(n4, n5, 9);32var e9 = new Edge(n4, n6, 14);33var e10 = new Edge(n5, n6, 10);34var e11 = new Edge(n6, n7, 2);35var e12 = new Edge(n7, n8, 1);36var e13 = new Edge(n7, n9, 6);37var e14 = new Edge(n8, n9, 7);38g.addEdge(e1);39g.addEdge(e2);40g.addEdge(e3);41g.addEdge(e4);42g.addEdge(e5);43g.addEdge(e6);44g.addEdge(e7);45g.addEdge(e8);46g.addEdge(e9);47g.addEdge(e10);48g.addEdge(e11);49g.addEdge(e12);50g.addEdge(e13);

Full Screen

Using AI Code Generation

copy

Full Screen

1var g = new Graph();2g.addNode("A");3g.addNode("B");4g.addNode("C");5g.addNode("D");6g.addNode("E");7g.addNode("F");8g.addNode("G");9g.addNode("H");10g.addNode("I");11g.addNode("J");12g.addNode("K");13g.addNode("L");14g.addNode("M");15g.addNode("N");16g.addNode("O");17g.addNode("P");18g.addNode("Q");19g.addNode("R");20g.addNode("S");21g.addNode("T");22g.addNode("U");23g.addNode("V");24g.addNode("W");25g.addNode("X");26g.addNode("Y");27g.addNode("Z");28g.addEdge("A", "B", 1);29g.addEdge("A", "C", 1);30g.addEdge("A", "D", 1);31g.addEdge("A", "E", 1);32g.addEdge("B", "F", 1);33g.addEdge("B", "G", 1);34g.addEdge("B", "H", 1);35g.addEdge("B", "I", 1);36g.addEdge("C", "J", 1);37g.addEdge("C", "K", 1);38g.addEdge("C", "L", 1);39g.addEdge("C", "M", 1);40g.addEdge("D", "N", 1);41g.addEdge("D", "O", 1);42g.addEdge("D", "P", 1);43g.addEdge("D", "Q", 1);44g.addEdge("E", "R", 1);45g.addEdge("E", "S", 1);46g.addEdge("E", "T", 1);47g.addEdge("E", "U", 1);48g.addEdge("F", "V", 1);49g.addEdge("F", "W", 1);50g.addEdge("F", "X", 1);51g.addEdge("F", "Y", 1);52g.addEdge("G", "Z", 1);53g.addEdge("G", "A", 1);54g.addEdge("G", "B", 1);55g.addEdge("G", "C", 1);56g.addEdge("H", "D", 1);57g.addEdge("H", "E", 1

Full Screen

Using AI Code Generation

copy

Full Screen

1var fs = require('fs');2var bestPath = require('./bestPath.js');3var data = fs.readFileSync('input.txt', 'utf8');4var lines = data.split('5');6var firstLine = lines[0];7var firstLineArray = firstLine.split(' ');8var numNodes = firstLineArray[0];9var numEdges = firstLineArray[1];10var source = firstLineArray[2];11var dest = firstLineArray[3];12var bp = new bestPath.BestPath(numNodes);13for(var i = 1; i < lines.length; i++){14 var lineArray = lines[i].split(' ');15 var sourceNode = lineArray[0];16 var destNode = lineArray[1];17 var distance = lineArray[2];18 bp.addEdge(sourceNode, destNode, distance);19}20var path = bp.distDir(source, dest);21console.log(path);22console.log(bp.getDistance(path));23function BestPath(numNodes){24 this.adjList = new Array(numNodes);25 this.distance = new Array(numNodes);26 this.path = new Array(numNodes);27 this.visited = new Array(numNodes);28 this.pq = new PriorityQueue(numNodes);

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Best automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful