UNPKG

792 BPlain TextView Raw
1#!/usr/bin/env node
2
3const AssetGraph = require('../lib/AssetGraph');
4const urlTools = require('urltools');
5const commandLineOptions = require('yargs')
6 .usage('$0 image1 image2...')
7 .demand(1).argv;
8
9new AssetGraph({ root: commandLineOptions.root })
10 .logEvents({
11 repl: commandLineOptions.repl,
12 stopOnWarning: commandLineOptions.stoponwarning,
13 suppressJavaScriptCommonJsRequireWarnings: true,
14 })
15 .loadAssets(commandLineOptions._.map(urlTools.fsFilePathToFileUrl))
16 .queue(function () {
17 console.warn('BEFORE:');
18 })
19 .writeStatsToStderr()
20 .processImages({ isImage: true }, { autoLossless: true })
21 .writeAssetsToDisc({ protocol: 'file:', isImage: true, isDirty: true })
22 .queue(function () {
23 console.warn('\nAFTER:');
24 })
25 .writeStatsToStderr()
26 .run();