Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "xo/esnext",
"extends": "xo",
"rules": {
"semi": [
"error",
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ jobs:

strategy:
matrix:
node-version: [10.x, 12.x, 14.x]
node-version: [14.x, 16.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
Expand Down
23 changes: 13 additions & 10 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/setup-node@v2
with:
node-version: 12
node-version: '16.x'
- run: npm ci
- run: npm test

Expand All @@ -23,25 +23,28 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/setup-node@v2
with:
node-version: 12
registry-url: https://registry.npmjs.org/
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

publish-gpr:
needs: build
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/setup-node@v2
with:
node-version: 12
registry-url: https://npm.pkg.github.com/
node-version: '16.x'
registry-url: 'https://npm.pkg.github.com'
- run: npm ci
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion cli.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node

const diff = require('./lib/diff')
import diff from './lib/diff.js'

const output = ({error, result}) => {
if (error) {
Expand Down
18 changes: 9 additions & 9 deletions cli.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const {spawn} = require('child_process')
const test = require('tape')
import {spawn} from 'node:child_process'
import test from 'tape'

const run = async args => {
const stderr = []
Expand Down Expand Up @@ -57,10 +57,10 @@ test('cli, when using tree with missing files', async assert => {
'06.txt',
'07.txt',
'08.txt',
'09.txt'
].join('\n')
'09.txt',
].join('\n'),
],
code: 0
code: 0,
}

assert.deepEqual(actual, expected, message)
Expand All @@ -75,7 +75,7 @@ test('cli, when using invalid source directory', async assert => {
const expected = {
stderr: ['invalid path provided "./fixtures/invalid" (ENOENT)'],
stdout: [],
code: 1
code: 1,
}

assert.deepEqual(actual, expected, message)
Expand All @@ -90,7 +90,7 @@ test('cli, when using invalid target directory', async assert => {
const expected = {
stderr: ['invalid path provided "./fixtures/invalid" (ENOENT)'],
stdout: [],
code: 1
code: 1,
}

assert.deepEqual(actual, expected, message)
Expand All @@ -105,7 +105,7 @@ test('cli, when using file as source directory', async assert => {
const expected = {
stderr: ['invalid path provided "./fixtures/file.txt"; given file, expected directory (ENOTDIR)'],
stdout: [],
code: 1
code: 1,
}

assert.deepEqual(actual, expected, message)
Expand All @@ -120,7 +120,7 @@ test('cli, when using file as target directory', async assert => {
const expected = {
stderr: ['invalid path provided "./fixtures/file.txt"; given file, expected directory (ENOTDIR)'],
stdout: [],
code: 1
code: 1,
}

assert.deepEqual(actual, expected, message)
Expand Down
4 changes: 2 additions & 2 deletions lib/diff.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const list = require('./list')
import list from './list.js'

const diff = async ({source, target}) => {
const left = await list(source)
Expand All @@ -11,4 +11,4 @@ const diff = async ({source, target}) => {
.map(file => file.name)
}

module.exports = diff
export default diff
20 changes: 10 additions & 10 deletions lib/diff.test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const test = require('tape')
const diff = require('./diff')
import test from 'tape'
import diff from './diff.js'

test('diff files, when using same tree', async assert => {
const message = 'diff result must be empty'

const actual = await diff({
source: './fixtures/source',
target: './fixtures/source'
target: './fixtures/source',
})
const expected = []

Expand All @@ -20,7 +20,7 @@ test('diff files, when using distinct tree', async assert => {

const actual = await diff({
source: './fixtures/source',
target: './fixtures/target'
target: './fixtures/target',
})
const expected = []

Expand All @@ -34,7 +34,7 @@ test('diff files, when using tree with missing files', async assert => {

const actual = await diff({
source: './fixtures/source',
target: './fixtures/target/a'
target: './fixtures/target/a',
})
const expected = [
'00.txt',
Expand All @@ -44,7 +44,7 @@ test('diff files, when using tree with missing files', async assert => {
'06.txt',
'07.txt',
'08.txt',
'09.txt'
'09.txt',
]

assert.deepEqual(actual, expected, message)
Expand All @@ -58,7 +58,7 @@ test('diff files, when using invalid source directory', async assert => {
try {
await diff({
source: './fixtures/invalid',
target: './fixtures/target'
target: './fixtures/target',
})

assert.fail(message)
Expand All @@ -78,7 +78,7 @@ test('diff files, when using invalid target directory', async assert => {
try {
await diff({
source: './fixtures/source',
target: './fixtures/invalid'
target: './fixtures/invalid',
})

assert.fail(message)
Expand All @@ -98,7 +98,7 @@ test('diff files, when using file as source directory', async assert => {
try {
await diff({
source: './fixtures/file.txt',
target: './fixtures/target'
target: './fixtures/target',
})

assert.fail(message)
Expand All @@ -118,7 +118,7 @@ test('diff files, when using file as target directory', async assert => {
try {
await diff({
source: './fixtures/source',
target: './fixtures/file.txt'
target: './fixtures/file.txt',
})

assert.fail(message)
Expand Down
6 changes: 3 additions & 3 deletions lib/list.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const path = require('path')
const fs = require('fs').promises
import path from 'node:path'
import fs from 'node:fs/promises'

const list = async pathdir => {
try {
Expand Down Expand Up @@ -27,4 +27,4 @@ const list = async pathdir => {
}
}

module.exports = list
export default list
8 changes: 4 additions & 4 deletions lib/list.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const test = require('tape')
const list = require('./list')
import test from 'tape'
import list from './list.js'

test('list files, when using flat tree', async assert => {
const message = 'should list 10 files'
Expand All @@ -15,7 +15,7 @@ test('list files, when using flat tree', async assert => {
{path: 'fixtures/source', name: '06.txt'},
{path: 'fixtures/source', name: '07.txt'},
{path: 'fixtures/source', name: '08.txt'},
{path: 'fixtures/source', name: '09.txt'}
{path: 'fixtures/source', name: '09.txt'},
]

assert.deepEqual(actual, expected, message)
Expand All @@ -37,7 +37,7 @@ test('list files, when using tree with branches', async assert => {
{path: 'fixtures/target/b', name: '03.txt'},
{path: 'fixtures/target/b/b', name: '04.txt'},
{path: 'fixtures/target/c', name: '05.txt'},
{path: 'fixtures/target/c/c', name: '06.txt'}
{path: 'fixtures/target/c/c', name: '06.txt'},
]

assert.deepEqual(actual, expected, message)
Expand Down
Loading