Skip to content

Commit 073704b

Browse files
committed
Update dependencies and use esbuild for bundling
You may wonder why all these changes are done in one commit, and that's because they're all kind of interrelated: - I initially updated PureScript to 0.15.x, which produces code that uses ES modules instead of CommonJS ones - The version of `purescript-decimals` in the 0.15.x package set was tested with decimal.js 10.3.1, so use that - Since we're using ES modules now, I updated `clipboardy` and `xdg-basedir` to versions that use ES modules (I admit that I didn't have to do this one in this commit) - `pulp browserify` doesn't work with PureScript 0.15.x, so I had to migrate to something else (I chose `esbuild`) Side note: `purescript-parsing` 9.0.0 brings with it a wonderful performance boost[1], which speeds up the test suite considerably. [1]: purescript-contrib/purescript-parsing#154
1 parent 31820cb commit 073704b

File tree

8 files changed

+1397
-654
lines changed

8 files changed

+1397
-654
lines changed

copy.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
const { copyFileSync } = require("fs");
1+
import { copyFileSync } from "fs";
22

3-
copyFileSync("insect.js", "web/insect.js");
43
copyFileSync("node_modules/keyboardevent-key-polyfill/index.js", "web/keyboardevent-key-polyfill.js");
54
copyFileSync("node_modules/jquery/dist/jquery.min.js", "web/jquery.min.js");
65
copyFileSync("node_modules/jquery.terminal/js/jquery.terminal.min.js", "web/jquery.terminal.min.js");

index.js

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
#!/usr/bin/env node
22

3-
var os = require("os");
4-
var path = require("path");
5-
var Insect = require('./output/Insect/index.js');
3+
import * as Insect from "./output/Insect/index.js";
4+
import * as clipboardy from "clipboardy";
5+
import * as fs from "fs";
6+
import * as lineReader from "line-reader";
7+
import * as path from "path";
8+
import * as readline from "readline";
9+
import { homedir } from "os";
10+
import { xdgData } from "xdg-basedir";
611

712
var insectEnv = Insect.initialEnvironment;
813

@@ -46,8 +51,7 @@ if (process.argv.length >= 4) {
4651
}
4752

4853
if (process.env.INSECT_NO_RC !== "true") {
49-
var lineReader = require("line-reader");
50-
var rcFile = path.join(os.homedir(), ".insectrc");
54+
var rcFile = path.join(homedir(), ".insectrc");
5155
lineReader.eachLine(rcFile, function (line) {
5256
var res = runInsect(Insect.fmtPlain, line);
5357
// We really only care when it breaks
@@ -71,14 +75,8 @@ function startInsect() {
7175
var interactive = process.stdin.isTTY;
7276

7377
if (interactive) {
74-
var readline = require('readline');
75-
var xdgBasedir = require('xdg-basedir');
76-
var path = require('path');
77-
var clipboardy = require('clipboardy');
78-
var fs = require('fs');
79-
8078
// Open the history file for reading and appending.
81-
var historyFd = fs.openSync(path.join(xdgBasedir.data, "insect-history"), 'a+');
79+
var historyFd = fs.openSync(path.join(xdgData, "insect-history"), 'a+');
8280

8381
var maxHistoryLength = 5000;
8482

@@ -162,10 +160,6 @@ function startInsect() {
162160
rl.prompt();
163161
} else {
164162
// Read from non-interactive stream (shell pipe)
165-
166-
if (typeof lineReader === "undefined") {
167-
var lineReader = require("line-reader");
168-
}
169163
lineReader.eachLine(process.stdin, function(line) {
170164
var res = runInsect(Insect.fmtPlain, line);
171165
if (res) {

0 commit comments

Comments
 (0)