Last change
on this file since fa375fe was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.2 KB
|
Line | |
---|
1 | #!/usr/bin/env node
|
---|
2 |
|
---|
3 | 'use strict';
|
---|
4 |
|
---|
5 | process.title = 'mime';
|
---|
6 | let mime = require('.');
|
---|
7 | let pkg = require('./package.json');
|
---|
8 | let args = process.argv.splice(2);
|
---|
9 |
|
---|
10 | if (args.includes('--version') || args.includes('-v') || args.includes('--v')) {
|
---|
11 | console.log(pkg.version);
|
---|
12 | process.exit(0);
|
---|
13 | } else if (args.includes('--name') || args.includes('-n') || args.includes('--n')) {
|
---|
14 | console.log(pkg.name);
|
---|
15 | process.exit(0);
|
---|
16 | } else if (args.includes('--help') || args.includes('-h') || args.includes('--h')) {
|
---|
17 | console.log(pkg.name + ' - ' + pkg.description + '\n');
|
---|
18 | console.log(`Usage:
|
---|
19 |
|
---|
20 | mime [flags] [path_or_extension]
|
---|
21 |
|
---|
22 | Flags:
|
---|
23 | --help, -h Show this message
|
---|
24 | --version, -v Display the version
|
---|
25 | --name, -n Print the name of the program
|
---|
26 |
|
---|
27 | Note: the command will exit after it executes if a command is specified
|
---|
28 | The path_or_extension is the path to the file or the extension of the file.
|
---|
29 |
|
---|
30 | Examples:
|
---|
31 | mime --help
|
---|
32 | mime --version
|
---|
33 | mime --name
|
---|
34 | mime -v
|
---|
35 | mime src/log.js
|
---|
36 | mime new.py
|
---|
37 | mime foo.sh
|
---|
38 | `);
|
---|
39 | process.exit(0);
|
---|
40 | }
|
---|
41 |
|
---|
42 | let file = args[0];
|
---|
43 | let type = mime.getType(file);
|
---|
44 |
|
---|
45 | process.stdout.write(type + '\n');
|
---|
46 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.