path#resolve JavaScript Examples
The following examples show how to use
path#resolve.
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: utils.js From IBM-db2-blockchain-insurance-application with Apache License 2.0 | 7 votes |
async createChannel(envelope) {
const txId = this._client.newTransactionID();
const channelConfig = this._client.extractChannelConfig(envelope);
const signature = this._client.signChannelConfig(channelConfig);
const request = {
name: this._channelName,
orderer: this._channel.getOrderers()[0],
config: channelConfig,
signatures: [signature],
txId
};
const response = await this._client.createChannel(request);
// Wait for 5sec to create channel
await new Promise(resolve => {
setTimeout(resolve, 5000);
});
return response;
}
Example #2
Source File: vite.config.js From viv with MIT License | 6 votes |
configViv = defineConfig({
plugins,
worker: {
format: "es",
rollupOptions: { inlineDynamicImports: true },
},
build: {
target: 'esnext',
minify: false,
lib: {
entry: resolve(__dirname, 'src/index.js'),
formats: ['es'],
},
rollupOptions: {
// All non-relative paths are external
external: [/^[^.\/]|^\.[^.\/]|^\.\.[^\/]/],
},
},
})
Example #3
Source File: json2dsv.js From cs-wiki with GNU General Public License v3.0 | 6 votes |
options = program
.version(JSON.parse(readFileSync(resolve(dirname(fileURLToPath(import.meta.url)), "../package.json"))).version)
.usage("[options] [file]")
.option("-o, --out <file>", "output file name; defaults to “-” for stdout", "-")
.option("-w, --output-delimiter <character>", "output delimiter character", defaultOutDelimiter)
.option("-n, --newline-delimited", "accept newline-delimited JSON")
.option("--input-encoding <encoding>", "input character encoding; defaults to “utf8”", "utf8")
.option("--output-encoding <encoding>", "output character encoding; defaults to “utf8”", "utf8")
.parse(process.argv)
.opts()
Example #4
Source File: index.js From bakabo with GNU General Public License v3.0 | 6 votes |
parser = new YargsParser({
cwd: process.cwd,
env: () => {
return env;
},
format,
normalize,
resolve,
// TODO: figure out a way to combine ESM and CJS coverage, such that
// we can exercise all the lines below:
require: (path) => {
if (typeof require !== 'undefined') {
return require(path);
}
else if (path.match(/\.json$/)) {
return readFileSync(path, 'utf8');
}
else {
throw Error('only .json config files are supported in ESM');
}
}
})
Example #5
Source File: index.es.js From smart-contracts with MIT License | 6 votes |
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
Example #6
Source File: configHelpers.js From twin.macro with MIT License | 6 votes |
getTailwindConfigProperties = (state, config) => {
const sourceRoot = state.file.opts.sourceRoot || '.'
const configFile = config && config.config
const baseDir = state.filename ? dirname(state.filename) : process.cwd()
const configPath = configFile
? resolve(sourceRoot, configFile)
: escalade(baseDir, (_dir, names) => {
if (names.includes('tailwind.config.js')) {
return 'tailwind.config.js'
}
if (names.includes('tailwind.config.cjs')) {
return 'tailwind.config.cjs'
}
})
const configExists = configPath && existsSync(configPath)
const configSelected = configExists
? requireFresh(configPath)
: defaultTailwindConfig
const configUser = silenceContentWarning(configSelected)
const tailwindConfig = resolveTailwindConfig([...getAllConfigs(configUser)])
throwIf(!tailwindConfig, () =>
logGeneralError(`Couldn’t find the Tailwind config.\nLooked in ${config}`)
)
return { configExists, tailwindConfig, configPath }
}
Example #7
Source File: get-source-map.js From Lambda with MIT License | 6 votes |
test('finds an external source map', async () => {
const file = fs
.readFileSync(resolve(__dirname, '../../fixtures/bundle.mjs'))
.toString('utf8');
fetch.mockResponseOnce(
fs
.readFileSync(resolve(__dirname, '../../fixtures/bundle.mjs.map'))
.toString('utf8')
);
const sm = await getSourceMap('/', file);
expect(sm.getOriginalPosition(26122, 21)).toEqual({
line: 7,
column: 0,
source: 'webpack:///packages/react-scripts/template/src/App.js',
});
});
Example #8
Source File: vite.config.js From viv with MIT License | 6 votes |
configAvivator = defineConfig({
plugins: [react(), ...plugins],
base: './',
root: 'avivator',
publicDir: 'avivator/public',
worker: {
format: "es",
rollupOptions: { inlineDynamicImports: true },
},
resolve: {
alias: {
'@hms-dbmi/viv': resolve(__dirname, 'src'),
'react': resolve(__dirname, 'avivator/node_modules/react'),
'react-dom': resolve(__dirname, 'avivator/node_modules/react-dom'),
},
},
})
Example #9
Source File: Mail.js From FastFeet with MIT License | 6 votes |
cofigureTemplates() {
const viewPath = resolve(__dirname, '..', 'app', 'views', 'emails');
this.transporter.use(
'compile',
nodemailerhbs({
viewEngine: exphbs.create({
layoutsDir: resolve(viewPath, 'layouts'),
partialsDir: resolve(viewPath, 'partials'),
defaultLayout: 'default',
extname: '.hbs'
}),
viewPath,
extName: '.hbs'
})
);
}
Example #10
Source File: source-map-support.js From playwright-test with MIT License | 6 votes |
// Support URLs relative to a directory, but be careful about a protocol prefix
// in case we are in the browser (i.e. directories may start with "http://" or "file:///")
function supportRelativeURL(file, url, tweak) {
if (!file) {
return url
}
const dir = dirname(file)
const match = /^\w+:\/\/[^\/]*/.exec(dir)
let protocol = match ? match[0] : ''
const startPath = dir.slice(protocol.length)
if (protocol && /^\/\w\:/.test(startPath)) {
// handle file:///C:/ paths
protocol += '/'
return (
protocol + resolve(dir.slice(protocol.length), url).replace(/\\/g, '/')
)
}
if (tweak && PW_TEST_SOURCEMAP === true) {
return resolve(PW_TEST_SOURCEMAP_PATH, url)
// return PW_TEST_SOURCEMAP_PATH + resolve(dir.slice(protocol.length), url)
}
return protocol + resolve(dir.slice(protocol.length), url)
}
Example #11
Source File: index.js From nuxt-gsap-module with MIT License | 6 votes |
export default function gsapModule(moduleOptions) {
const { nuxt, addPlugin } = this
const options = {
extraPlugins: {},
extraEases: {},
clubPlugins: {},
registerEffect: [],
registerEase: [],
...nuxt.options.gsap,
...moduleOptions
}
addPlugin({
src: resolve(__dirname, '../templates/plugin.js'),
fileName: 'gsapModule.js',
options
})
}
Example #12
Source File: cli.js From ZzFXM with MIT License | 6 votes |
options = cli({
name: 'ZzFXM Song Conversion Tool',
packageJson: resolve(dirname(fileURLToPath(import.meta.url)), 'package.json'),
inputPaths: 'single',
outputPath: 'optional',
options: [
{ name: 'ignore-errors', alias: 'i', type: Boolean, description: 'Ignore incompatability errors with ZzxFM and the source song.' },
{ name: 'no-instruments', alias: 'n', type: Boolean, description: 'Don\'t generate instrument data.'},
{ name: 'sane-instruments', alias: 's', type: Boolean, description: 'Only generate data for known instruments.'},
{ name: 'pretty-print', alias: 'p', type: Boolean, description: 'Generate human-readable output file.'},
{ name: 'format', alias: 'f', values: ['none', 'esm'], type: String, description: `Output format.`, defaultValue: 'none'},
]
})
Example #13
Source File: index.js From watchlist with MIT License | 6 votes |
export async function watch(list, callback, opts={}) {
const cwd = resolve('.', opts.cwd || '.');
const dirs = new Set(list.map(str => resolve(cwd, str)).filter(existsSync));
const ignores = ['node_modules'].concat(opts.ignore || []).map(x => new RegExp(x, 'i'));
let wip = 0;
const Triggers = new Set;
const Watchers = new Map;
async function handle() {
await callback();
if (--wip) return handle();
}
// TODO: Catch `EPERM` on Windows for removed dir
async function onChange(dir, type, filename) {
if (ignores.some(x => x.test(filename))) return;
let tmp = join(dir, filename);
if (Triggers.has(tmp)) return;
if (wip++) return wip = 1;
if (opts.clear) console.clear();
Triggers.add(tmp);
await handle();
Triggers.delete(tmp);
}
let dir, output, key;
for (dir of dirs) {
output = await setup(dir, onChange);
for (key in output) Watchers.set(key, output[key]);
}
if (opts.eager) {
await callback();
}
}
Example #14
Source File: file.js From flow-cadut with Apache License 2.0 | 6 votes |
getFilesList = async (dir) => {
const dirents = await fs.promises.readdir(dir, { withFileTypes: true });
const files = await Promise.all(
dirents.map((dirent) => {
const res = resolve(dir, dirent.name);
return dirent.isDirectory() ? getFilesList(res) : res;
})
);
return files.flat();
}
Example #15
Source File: index.js From kit with MIT License | 6 votes |
/**
* @param {NetlifyConfig} netlify_config
* @param {import('@sveltejs/kit').Builder} builder
**/
function get_publish_directory(netlify_config, builder) {
if (netlify_config) {
if (!netlify_config.build?.publish) {
builder.log.minor('No publish directory specified in netlify.toml, using default');
return;
}
if (netlify_config.redirects) {
throw new Error(
"Redirects are not supported in netlify.toml. Use _redirects instead. For more details consult the readme's troubleshooting section."
);
}
if (resolve(netlify_config.build.publish) === process.cwd()) {
throw new Error(
'The publish directory cannot be set to the site root. Please change it to another value such as "build" in netlify.toml.'
);
}
return netlify_config.build.publish;
}
builder.log.warn(
'No netlify.toml found. Using default publish directory. Consult https://github.com/sveltejs/kit/tree/master/packages/adapter-netlify#configuration for more details '
);
}
Example #16
Source File: path.js From bot with GNU General Public License v3.0 | 6 votes |
/**
* pathTo is a oneline solution for resolving path.resolve(__dirname, 'something.js') to an absolute path.
* I created this as a replacement for desm, because you don't need another
* npm package just for resolving this one.
* @param {ImportMeta.url} url import.meta.url
* @param {String} path
* @returns {import("fs").PathLike} Absolute path from the given path string
* @example
* // Say we call the function from src/app.js
* const envPath = pathTo('../env') // returns the full .env path outside the src dir
* const redisPath = pathTo('./utils/redis.js') // returns what you expect.
*/
export function pathTo(url, path) {
return resolve(dirname(fileURLToPath(url)), path);
}
Example #17
Source File: build-dev-leaflet.js From web-component-plus with Apache License 2.0 | 6 votes |
// 整合打;包
config.push({
input: resolve(__dirname, "../src/index.ts"),
plugins: [
url(),
nodeResolve(),
commonjs(),
postcss({
extensions: [ '.css', 'scss' ],
name: 'index',
to: `${output}/index.css`,
plugins: [
autoprefixer()
],
// extract: `${output}/index.css`
extract: false
}),
typescript({
tsconfig: getPath('../tsconfig.json'), // 导入本地ts配置
tsconfigDefaults: defaults,
tsconfigOverride: {
compilerOptions: {
declaration: true
}
},
extensions
}),
json(),
replace({
preventAssignment: true
})
],
output: [
{ name: 'WebUIPlus', file: `${output}/web-plus.umd.js`, format: 'umd' },
// { file: `${output}/web-plus.cjs.js`, format: 'cjs' },
// { file: `${output}/web-plus.esm.js`, format: 'es' }
]
})
Example #18
Source File: dsv2dsv.js From cs-wiki with GNU General Public License v3.0 | 6 votes |
options = program
.version(JSON.parse(readFileSync(resolve(dirname(fileURLToPath(import.meta.url)), "../package.json"))).version)
.usage("[options] [file]")
.option("-o, --out <file>", "output file name; defaults to “-” for stdout", "-")
.option("-r, --input-delimiter <character>", "input delimiter character", defaultInDelimiter)
.option("-w, --output-delimiter <character>", "output delimiter character", defaultOutDelimiter)
.option("--input-encoding <encoding>", "input character encoding; defaults to “utf8”", "utf8")
.option("--output-encoding <encoding>", "output character encoding; defaults to “utf8”", "utf8")
.parse(process.argv)
.opts()
Example #19
Source File: utils.js From IBM-db2-blockchain-insurance-application with Apache License 2.0 | 6 votes |
process.env.GOPATH = resolve(__dirname, '../../chaincode');
Example #20
Source File: database.js From HinataMd with GNU General Public License v3.0 | 6 votes |
/**
* Create new Database
* @param {String} filepath Path to specified json database
* @param {...any} args JSON.stringify arguments
*/
constructor(filepath, ...args) {
this.file = resolve(filepath)
this.logger = console
this._load()
this._jsonargs = args
this._state = false
this._queue = []
this._interval = setInterval(async () => {
if (!this._state && this._queue && this._queue[0]) {
this._state = true
await this[this._queue.shift()]().catch(this.logger.error)
this._state = false
}
}, 1000)
}
Example #21
Source File: index.js From cs-wiki with GNU General Public License v3.0 | 6 votes |
async function findPackageJson(base, moduleDirs) {
const { root } = path.parse(base);
let current = base;
while (current !== root && !isModuleDir(current, moduleDirs)) {
const pkgJsonPath = path.join(current, 'package.json');
if (await fileExists(pkgJsonPath)) {
const pkgJsonString = fs.readFileSync(pkgJsonPath, 'utf-8');
return { pkgJson: JSON.parse(pkgJsonString), pkgPath: current, pkgJsonPath };
}
current = path.resolve(current, '..');
}
return null;
}
Example #22
Source File: index.js From URT-BOT with MIT License | 6 votes |
parser = new YargsParser({
cwd: process.cwd,
env: () => {
return env;
},
format,
normalize,
resolve,
// TODO: figure out a way to combine ESM and CJS coverage, such that
// we can exercise all the lines below:
require: (path) => {
if (typeof require !== 'undefined') {
return require(path);
}
else if (path.match(/\.json$/)) {
// Addresses: https://github.com/yargs/yargs/issues/2040
return JSON.parse(readFileSync(path, 'utf8'));
}
else {
throw Error('only .json config files are supported in ESM');
}
}
})
Example #23
Source File: dsv2json.js From cs-wiki with GNU General Public License v3.0 | 6 votes |
options = program
.version(JSON.parse(readFileSync(resolve(dirname(fileURLToPath(import.meta.url)), "../package.json"))).version)
.usage("[options] [file]")
.option("-o, --out <file>", "output file name; defaults to “-” for stdout", "-")
.option("-r, --input-delimiter <character>", "input delimiter character", defaultInDelimiter)
.option("-a, --auto-type", "parse rows with type inference (see d3.autoType)")
.option("-n, --newline-delimited", "output newline-delimited JSON")
.option("--input-encoding <encoding>", "input character encoding; defaults to “utf8”", "utf8")
.option("--output-encoding <encoding>", "output character encoding; defaults to “utf8”", "utf8")
.parse(process.argv)
.opts()
Example #24
Source File: laodeai.test.js From bot with GNU General Public License v3.0 | 5 votes |
readFile = (path) =>
readFileSync(resolve(dirname(fileURLToPath(import.meta.url)), path), {
encoding: "utf-8"
})
Example #25
Source File: app.js From api-denuncia-de-aglomeracao with GNU General Public License v3.0 | 5 votes |
middlewares() {
this.server.use(cors());
this.server.use(express.json());
this.server.use(
'/files',
express.static(resolve(__dirname, '..', 'tmp', 'uploads'))
); // see files uploaded in development
}
Example #26
Source File: App.js From react-electron-browser-view with MIT License | 5 votes |
preload = resolve('./example/src/preload.js')
Example #27
Source File: build.js From web-component-plus with Apache License 2.0 | 5 votes |
output = resolve(__dirname, "../dist")
Example #28
Source File: i18n.js From GooseMod with MIT License | 5 votes |
distDir = resolve(join(__dirname, '..', '..', 'dist'))
Example #29
Source File: build-dev-tree.js From web-component-plus with Apache License 2.0 | 5 votes |
getPath = _path => resolve(__dirname, _path)