Skip to content

Commit

Permalink
fix: fix path regex for win32
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub committed Sep 27, 2020
1 parent 36fc63f commit 376ec91
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 13 deletions.
39 changes: 28 additions & 11 deletions .travis.yml
@@ -1,13 +1,30 @@
language: node_js
node_js:
- "node"
after_script:
- npm run coveralls
node_js: 14

deploy:
provider: script
skip_cleanup: true
script:
- yarn semantic-release
on:
branch: master
jobs:
include:
- &test
stage: test
os: linux
install: yarn
script: yarn test
after_script: npm run coveralls
workspaces:
create:
name: shared
paths:
- node_modules

- <<: *test
os: windows
env: YARN_GPG=no
script: cli/synp.js -s yarn.lock
after_script: skip
workspaces:

- stage: release
if: branch = master AND type != pull_request
workspaces:
use: shared
install: skip
script: yarn release
5 changes: 3 additions & 2 deletions lib/lockfileV1/tree.js
@@ -1,6 +1,7 @@
'use strict'

const { sep, resolve } = require('path')
const { has } = require('lodash')
const sortObject = require('sort-object-keys')
const { dependenciesForYarn } = require('./dependencies')
const { yarnEntry, npmEntry } = require('./entry')
Expand Down Expand Up @@ -44,7 +45,7 @@ module.exports = {
return formattedTree
},
buildNpmTree (nodeModulesTree, yarnObject, workspacesTree) {
const countDepth = (path) => (path.match(new RegExp(`${sep}node_modules${sep}`, 'g')) || []).length
const countDepth = (path) => path.split(`${sep}node_modules${sep}`).length - 1
const sortedNodeModules = Object.keys(nodeModulesTree).sort((a, b) => countDepth(a) < countDepth(b) ? -1 : 1)
const basePath = sortedNodeModules[0].split(sep)

Expand All @@ -63,7 +64,7 @@ module.exports = {
entry.requires = sortObject(dependencies)
}

if ((nodeModulesTree[parentPackagePath(mPath)].devDependencies || {})[name]) {
if (has(nodeModulesTree[parentPackagePath(mPath)], `devDependencies.${name}`)) {
entry.dev = true
}

Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -18,6 +18,7 @@
"scripts": {
"test": "standard && npm run test:unit",
"test:unit": "tape ./test/*.spec.js",
"test:integration": "cli/synp.js -s yarn.lock",
"coverage": "nyc --reporter=lcov npm test",
"coveralls": "nyc npm test && nyc report --reporter=text-lcov | coveralls"
},
Expand Down

0 comments on commit 376ec91

Please sign in to comment.